Skip to content

Commit eeb18d7

Browse files
committed
Merge branch 'moderators' of https://github.com/tehviking/hackety-hack.com
2 parents 991ffb2 + 96fb06c commit eeb18d7

5 files changed

Lines changed: 14 additions & 2 deletions

File tree

app/assets/stylesheets/questions.css.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,8 @@
107107
background: rgba(158, 183,68, 0.1) url("accepted.png") 99% 0.5em no-repeat;
108108
}
109109
}
110+
111+
.move_question {
112+
float:right;
113+
padding-top:4px;
114+
}

app/models/ability.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ class Ability
44
def initialize(user)
55
user ||= User.new
66

7-
can :read, :all
7+
if user.moderator?
8+
can :manage, :all
9+
else
10+
can :read, :all
11+
end
812

913
unless user.new_record?
1014
can :create, [Question, Answer]

app/models/question.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ class Question
1414

1515
scope :newest_first, sort(:created_at.desc)
1616
scope :supports, where(:support => true )
17-
scope :no_supports, where(:support => nil)
17+
scope :no_supports, where('$or' => [{:support=> false}, {:support => nil}])
1818
end

app/models/user.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class User
88
key :username, String
99
key :email, String
1010
key :about, String
11+
key :moderator, Boolean
1112

1213
many :questions
1314
many :answers

app/views/questions/_list.html.haml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@
1111
%span.date= time_ago_in_words(list.created_at)
1212
ago
1313
.description= truncate(list.description, :length => 150)
14+
- if current_user && current_user.moderator?
15+
%div.move_question= link_to "Move to #{list.support? ? 'Questions' : 'Support'} »", question_path(list, :question => { :support => (list.support? ? "false" : "true") }), :method => :put, :class => "btn small info"

0 commit comments

Comments
 (0)