Skip to content

Commit

Permalink
#67 show gray
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Feb 6, 2020
1 parent 86a401d commit 53c58cc
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 19 deletions.
10 changes: 7 additions & 3 deletions views/layout.haml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,14 @@
- else
%a{href: login_link}
= '/login'
- if defined?(author) && the_author.karma.points >= 100
- if defined?(author)
%li
%a{href: iri.cut('/submit')}
= '/submit'
- if the_author.karma.points.negative?
%span.gray{title: 'You can\'t submit because your karma is too low'}
= '/submit'
- else
%a{href: iri.cut('/submit')}
= '/submit'
- if defined?(author)
%li{title: 'Your karma'}
%a{href: iri.cut('/karma')}
Expand Down
36 changes: 22 additions & 14 deletions views/project.haml
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,34 @@
&= r[:author]
%span.item
= RelativeTime.in_words(r[:created])
- if the_author.karma.points >= 100
%span.item
= r[:up]
%span.item
= r[:up]
- if the_author.karma.points >= 100
%a{href: iri.cut('/p').append(project.id).append('r').append(r[:id]).append('up')}
= '/up'
- if the_author.karma.points >= 200
%span.item
= r[:down]
- else
%span.gray{title: 'You can\'t upvote because your karma is too low'}
= '/up'
%span.item
= r[:down]
- if the_author.karma.points >= 200
%a{href: iri.cut('/p').append(project.id).append('r').append(r[:id]).append('down')}
= '/down'
- if the_author.karma.points >= 500
%span.item
- else
%span.gray{title: 'You can\'t down-vote because your karma is too low'}
= '/down'
%span.item
- if the_author.karma.points >= 500
%a{href: iri.cut('/p').append(project.id).append('r').append(r[:id]).append('delete')}
= '/delete'
- else
%span.gray{title: 'You can\'t delete this review because your karma is too low'}
= '/delete'
%br
&= r[:text].gsub('\n\n', '<br/><br/>')

- if the_author.karma.points >= 50
%form{action: iri.cut('/p').append(project.id).append('post'), method: 'POST'}
%fieldset
%label What do you think about it?
%textarea{name: 'text', style: 'width: 100%; height: 8em;'}
%button{type: 'submit'} Post
%form{action: iri.cut('/p').append(project.id).append('post'), method: 'POST'}
%fieldset
%label What do you think about it?
%textarea{name: 'text', style: 'width: 100%; height: 8em;', readonly: the_author.karma.points.negative?}
%button{type: 'submit', disabled: the_author.karma.points.negative?} Post
7 changes: 5 additions & 2 deletions views/recent.haml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
&= p[:author]
%span.item
= RelativeTime.in_words(p[:created])
- if the_author.karma.points >= 500
%span.item
%span.item
- if the_author.karma.points >= 500
%a{href: iri.cut('/p').append(p[:id]).append('delete')}
= '/delete'
- else
%span.gray{title: 'You can\'t delete this project because your karma is too low'}
= '/delete'

0 comments on commit 53c58cc

Please sign in to comment.