Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5324 create new role moderator #6351

Conversation

zaziemo
Copy link
Contributor

@zaziemo zaziemo commented Aug 26, 2015

The people who are assigned the moderator role should be able to see, mark and delete reported comments/posts. They also should get an email when a new post/comment is reported. Mostly everything works fine, only the email's language doesn't change according to the person's language settings (it takes the language settings of the first one).

@@ -150,7 +157,7 @@ def gon_set_current_user
return unless user_signed_in?
a_ids = session[:a_ids] || []
user = UserPresenter.new(current_user, a_ids)
gon.push({:user => user})
gon.push({user: user})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant curly braces around a hash parameter.

@Flaburgan
Copy link
Member

Awesome <3

@@ -94,6 +94,9 @@
{{#if current_user.admin}}
<li><a href="/admins/dashboard">{{t "header.admin"}}</a></li>
{{/if}}
{{#if current_user.moderator}}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's rather use obvious predicate methods here:

current_user.moderator?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a Handlebars template rendered on the client side, not Ruby ;)

@Realtin Realtin force-pushed the 5324-create-new-role-moderator branch from a84c411 to 76e533e Compare September 1, 2015 09:40
@Realtin
Copy link
Contributor

Realtin commented Sep 1, 2015

Ok this should be ready to merge.
I squashed the refactor commits. do you want more squashed? (I'm getting a hang of it now..)

@@ -17,6 +18,14 @@ def self.add_admin(person)
find_or_create_by(person_id: person.id, name: "admin")
end

def self.moderator?(person)
exists?(person_id: person.id, name: "moderator")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be moderators.exists?(person_id: person.id) and then the || current_user.admin? above shouldn't be needed anymore.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And then three specs would be awesome, expect(Role.moderator?(admin_person)).to be_true, expect(Role.moderator?(moderator_person)).to be_true, expect(Role.moderator?(normal_person)).to be_false

@Realtin
Copy link
Contributor

Realtin commented Sep 2, 2015

We added the specs and refactored the method. what do you think?

@jhass
Copy link
Member

jhass commented Sep 2, 2015

I think we're almost done here. I'd like the three specs for Role.moderator?(some_person) specifically, but the ones for the scope are good too, so don't drop them.

@zaziemo
Copy link
Contributor Author

zaziemo commented Sep 2, 2015

@jhass do you mean in the same document but outside the scope?

it "should not include normal users" do
expect(Role.moderators).to_not include(person)
end
end
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. I'm saying that these tests are for the scope moderators and it's good to have them, but I'd also like to see them for Role.moderator?(person), like we have specs for Role.is_admin?(person) below.

@zaziemo zaziemo force-pushed the 5324-create-new-role-moderator branch from 61f048a to 81d82dc Compare September 7, 2015 08:40
@zaziemo zaziemo changed the title [WIP] 5324 create new role moderator 5324 create new role moderator Sep 7, 2015
@zaziemo
Copy link
Contributor Author

zaziemo commented Sep 7, 2015

@jhass should be ready now. We rebased to the current develop state.
Travis fails are caused by the cucumber tests.

@jhass jhass added this to the 0.5.4.0 milestone Sep 7, 2015
@jhass
Copy link
Member

jhass commented Sep 7, 2015

Merged as d38741d c2c6ed5 15b1865 098c30c 0b420d0 b2dc77e bc75371 3a3c881

Thank you!

@jhass jhass closed this in d38741d Sep 7, 2015
@Flaburgan
Copy link
Member

Nice! Thank you!

@Flaburgan
Copy link
Member

@zaziemo can you also edit the wiki to indicate to podmin how to turn a user into a moderator?

@zaziemo
Copy link
Contributor Author

zaziemo commented Sep 7, 2015

@Flaburgan sure. How do I indicate that the feature will only be available with the next release?

@jhass
Copy link
Member

jhass commented Sep 7, 2015

Usually we do wiki updates only with the releases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants