FEATURE: New modal to show flags received for a user
This commit is contained in:
parent
ec65ae76b9
commit
34ed6088b9
|
@ -0,0 +1,3 @@
|
||||||
|
export default Ember.Component.extend({
|
||||||
|
classNames: ['flag-user-lists']
|
||||||
|
});
|
|
@ -0,0 +1,3 @@
|
||||||
|
export default Ember.Component.extend({
|
||||||
|
tagName: 'h3'
|
||||||
|
});
|
|
@ -64,6 +64,9 @@ export default Ember.Controller.extend(CanCheckEmails, {
|
||||||
anonymize() { return this.get('model').anonymize(); },
|
anonymize() { return this.get('model').anonymize(); },
|
||||||
destroy() { return this.get('model').destroy(); },
|
destroy() { return this.get('model').destroy(); },
|
||||||
|
|
||||||
|
showFlagsReceived() {
|
||||||
|
this.get('adminTools').showFlagsReceived(this.get('model'));
|
||||||
|
},
|
||||||
showSuspendModal() {
|
showSuspendModal() {
|
||||||
this.get('adminTools').showSuspendModal(this.get('model'));
|
this.get('adminTools').showSuspendModal(this.get('model'));
|
||||||
},
|
},
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
export default Ember.Controller.extend({
|
||||||
|
loadingFlags: null,
|
||||||
|
user: null,
|
||||||
|
|
||||||
|
onShow() {
|
||||||
|
this.set('loadingFlags', true);
|
||||||
|
this.store.findAll('flagged-post', {
|
||||||
|
filter: 'without_custom',
|
||||||
|
user_id: this.get('model.id')
|
||||||
|
}).then(result => {
|
||||||
|
this.set('loadingFlags', false);
|
||||||
|
console.log(result);
|
||||||
|
this.set('flaggedPosts', result);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
|
@ -22,6 +22,11 @@ export default Post.extend({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@computed('post_actions')
|
||||||
|
hasDisposedBy() {
|
||||||
|
return this.get('post_actions').some(action => action.disposed_by);
|
||||||
|
},
|
||||||
|
|
||||||
@computed('post_actions.@each.name_key')
|
@computed('post_actions.@each.name_key')
|
||||||
flaggedForSpam() {
|
flaggedForSpam() {
|
||||||
return this.get('post_actions').every(action => action.name_key === 'spam');
|
return this.get('post_actions').every(action => action.name_key === 'spam');
|
||||||
|
|
|
@ -17,6 +17,10 @@ export default Ember.Service.extend({
|
||||||
this.siteSettings = getOwner(this).lookup('site-settings:main');
|
this.siteSettings = getOwner(this).lookup('site-settings:main');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
showFlagsReceived(user) {
|
||||||
|
showModal(`admin-flags-received`, { admin: true, model: user });
|
||||||
|
},
|
||||||
|
|
||||||
checkSpammer(userId) {
|
checkSpammer(userId) {
|
||||||
return AdminUser.find(userId).then(au => this.spammerDetails(au));
|
return AdminUser.find(userId).then(au => this.spammerDetails(au));
|
||||||
},
|
},
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
<div class='flagged-by'>
|
||||||
|
<div class='user-list-title'>
|
||||||
|
{{i18n "admin.flags.flagged_by"}}
|
||||||
|
</div>
|
||||||
|
<div class='flag-users'>
|
||||||
|
{{#each flaggedPost.post_actions as |postAction|}}
|
||||||
|
{{#flag-user user=postAction.user date=postAction.created_at}}
|
||||||
|
<div class='flagger-flag-type'>
|
||||||
|
{{post-action-title postAction.post_action_type_id postAction.name_key}}
|
||||||
|
</div>
|
||||||
|
{{/flag-user}}
|
||||||
|
{{/each}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{#if showResolvedBy}}
|
||||||
|
<div class='flagged-post-resolved-by'>
|
||||||
|
<div class='user-list-title'>
|
||||||
|
{{i18n "admin.flags.resolved_by"}}
|
||||||
|
</div>
|
||||||
|
<div class='flag-users'>
|
||||||
|
{{#each flaggedPost.post_actions as |postAction|}}
|
||||||
|
{{#flag-user user=postAction.disposed_by date=postAction.disposed_at}}
|
||||||
|
{{disposition-icon postAction.disposition}}
|
||||||
|
{{#if postAction.staff_took_action}}
|
||||||
|
{{d-icon "gavel" title="admin.flags.took_action"}}
|
||||||
|
{{/if}}
|
||||||
|
{{/flag-user}}
|
||||||
|
{{/each}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
|
@ -0,0 +1,5 @@
|
||||||
|
{{#if flaggedPost.topic.isPrivateMessage}}
|
||||||
|
<span class="private-message-glyph">{{d-icon "envelope"}}</span>
|
||||||
|
{{/if}}
|
||||||
|
{{topic-status topic=flaggedPost.topic}}
|
||||||
|
<a href='{{unbound flaggedPost.url}}'>{{{unbound flaggedPost.topic.fancyTitle}}}</a>
|
|
@ -30,13 +30,7 @@
|
||||||
|
|
||||||
<div class='flagged-post-excerpt'>
|
<div class='flagged-post-excerpt'>
|
||||||
{{#unless hideTitle}}
|
{{#unless hideTitle}}
|
||||||
<h3>
|
{{flagged-post-title flaggedPost=flaggedPost}}
|
||||||
{{#if flaggedPost.topic.isPrivateMessage}}
|
|
||||||
<span class="private-message-glyph">{{d-icon "envelope"}}</span>
|
|
||||||
{{/if}}
|
|
||||||
{{topic-status topic=flaggedPost.topic}}
|
|
||||||
<a href='{{unbound flaggedPost.url}}'>{{{unbound flaggedPost.topic.fancyTitle}}}</a>
|
|
||||||
</h3>
|
|
||||||
{{/unless}}
|
{{/unless}}
|
||||||
{{#if flaggedPost.postAuthorFlagged}}
|
{{#if flaggedPost.postAuthorFlagged}}
|
||||||
{{#if expanded}}
|
{{#if expanded}}
|
||||||
|
@ -72,40 +66,7 @@
|
||||||
</div>
|
</div>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
|
||||||
<div class='flag-user-lists'>
|
{{flag-user-lists flaggedPost=flaggedPost showResolvedBy=showResolvedBy}}
|
||||||
<div class='flagged-by'>
|
|
||||||
<div class='user-list-title'>
|
|
||||||
{{i18n "admin.flags.flagged_by"}}
|
|
||||||
</div>
|
|
||||||
<div class='flag-users'>
|
|
||||||
{{#each flaggedPost.post_actions as |postAction|}}
|
|
||||||
{{#flag-user user=postAction.user date=postAction.created_at}}
|
|
||||||
<div class='flagger-flag-type'>
|
|
||||||
{{post-action-title postAction.post_action_type_id postAction.name_key}}
|
|
||||||
</div>
|
|
||||||
{{/flag-user}}
|
|
||||||
{{/each}}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{{#if showResolvedBy}}
|
|
||||||
<div class='flagged-post-resolved-by'>
|
|
||||||
<div class='user-list-title'>
|
|
||||||
{{i18n "admin.flags.resolved_by"}}
|
|
||||||
</div>
|
|
||||||
<div class='flag-users'>
|
|
||||||
{{#each flaggedPost.post_actions as |postAction|}}
|
|
||||||
{{#flag-user user=postAction.disposed_by date=postAction.disposed_at}}
|
|
||||||
{{disposition-icon postAction.disposition}}
|
|
||||||
{{#if postAction.staff_took_action}}
|
|
||||||
{{d-icon "gavel" title="admin.flags.took_action"}}
|
|
||||||
{{/if}}
|
|
||||||
{{/flag-user}}
|
|
||||||
{{/each}}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{/if}}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{{#if suspended}}
|
{{#if suspended}}
|
||||||
<div class='suspended-message'>
|
<div class='suspended-message'>
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
{{#d-modal-body rawTitle=(i18n "admin.user.flags_received_by" username=model.username)}}
|
||||||
|
{{#conditional-loading-spinner condition=loadingFlags}}
|
||||||
|
{{#each flaggedPosts as |flaggedPost|}}
|
||||||
|
<div class='received-flag flagged-post'>
|
||||||
|
<div class='flagged-post-excerpt'>
|
||||||
|
{{flagged-post-title flaggedPost=flaggedPost}}
|
||||||
|
</div>
|
||||||
|
{{flag-user-lists flaggedPost=flaggedPost showResolvedBy=flaggedPost.hasDisposedBy}}
|
||||||
|
</div>
|
||||||
|
{{else}}
|
||||||
|
{{i18n "admin.user.flags_received_none"}}
|
||||||
|
{{/each}}
|
||||||
|
{{/conditional-loading-spinner}}
|
||||||
|
{{/d-modal-body}}
|
|
@ -6,6 +6,7 @@
|
||||||
{{i18n 'admin.user.show_public_profile'}}
|
{{i18n 'admin.user.show_public_profile'}}
|
||||||
{{/link-to}}
|
{{/link-to}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{#if model.can_view_action_logs}}
|
{{#if model.can_view_action_logs}}
|
||||||
{{d-button action="viewActionLogs" actionParam=model.username icon="list-alt" label="admin.user.action_logs"}}
|
{{d-button action="viewActionLogs" actionParam=model.username icon="list-alt" label="admin.user.action_logs"}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
@ -466,7 +467,18 @@
|
||||||
</div>
|
</div>
|
||||||
<div class='display-row'>
|
<div class='display-row'>
|
||||||
<div class='field'>{{i18n 'admin.user.flags_given_received_count'}}</div>
|
<div class='field'>{{i18n 'admin.user.flags_given_received_count'}}</div>
|
||||||
<div class='value'>{{model.flags_given_count}} / {{model.flags_received_count}}</div>
|
<div class='value'>
|
||||||
|
{{model.flags_given_count}} / {{model.flags_received_count}}
|
||||||
|
</div>
|
||||||
|
<div class='controls'>
|
||||||
|
{{#if model.flags_received_count}}
|
||||||
|
{{d-button
|
||||||
|
action=(action "showFlagsReceived")
|
||||||
|
label="admin.user.show_flags_received"
|
||||||
|
icon="flag"
|
||||||
|
}}
|
||||||
|
{{/if}}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class='display-row'>
|
<div class='display-row'>
|
||||||
<div class='field'>{{i18n 'admin.user.private_topics_count'}}</div>
|
<div class='field'>{{i18n 'admin.user.private_topics_count'}}</div>
|
||||||
|
|
|
@ -16,6 +16,7 @@ class Admin::FlagsController < Admin::AdminController
|
||||||
posts, topics, users, post_actions, total_rows = FlagQuery.flagged_posts_report(
|
posts, topics, users, post_actions, total_rows = FlagQuery.flagged_posts_report(
|
||||||
current_user,
|
current_user,
|
||||||
filter: params[:filter],
|
filter: params[:filter],
|
||||||
|
user_id: params[:user_id],
|
||||||
offset: offset,
|
offset: offset,
|
||||||
topic_id: params[:topic_id],
|
topic_id: params[:topic_id],
|
||||||
per_page: per_page,
|
per_page: per_page,
|
||||||
|
|
|
@ -3392,6 +3392,9 @@ en:
|
||||||
grant_moderation: 'Grant Moderation'
|
grant_moderation: 'Grant Moderation'
|
||||||
unsuspend: 'Unsuspend'
|
unsuspend: 'Unsuspend'
|
||||||
suspend: 'Suspend'
|
suspend: 'Suspend'
|
||||||
|
show_flags_received: "Show Flags Received"
|
||||||
|
flags_received_by: "Flags Received by %{username}"
|
||||||
|
flags_received_none: "This user has not received any flags."
|
||||||
reputation: Reputation
|
reputation: Reputation
|
||||||
permissions: Permissions
|
permissions: Permissions
|
||||||
activity: Activity
|
activity: Activity
|
||||||
|
|
|
@ -145,6 +145,16 @@ module FlagQuery
|
||||||
post_actions = post_actions.where("topics.id = ?", opts[:topic_id])
|
post_actions = post_actions.where("topics.id = ?", opts[:topic_id])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if opts[:user_id]
|
||||||
|
post_actions = post_actions.where("posts.user_id = ?", opts[:user_id])
|
||||||
|
end
|
||||||
|
|
||||||
|
if opts[:filter] == 'without_custom'
|
||||||
|
return post_actions.where(
|
||||||
|
'post_action_type_id' => PostActionType.flag_types_without_custom.values
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
if opts[:filter] == "old"
|
if opts[:filter] == "old"
|
||||||
post_actions.where("post_actions.disagreed_at IS NOT NULL OR
|
post_actions.where("post_actions.disagreed_at IS NOT NULL OR
|
||||||
post_actions.deferred_at IS NOT NULL OR
|
post_actions.deferred_at IS NOT NULL OR
|
||||||
|
|
|
@ -59,6 +59,12 @@ describe FlagQuery do
|
||||||
posts = FlagQuery.flagged_posts_report(admin, topic_id: -1)
|
posts = FlagQuery.flagged_posts_report(admin, topic_id: -1)
|
||||||
expect(posts[0]).to be_blank
|
expect(posts[0]).to be_blank
|
||||||
|
|
||||||
|
# Try by user
|
||||||
|
posts = FlagQuery.flagged_posts_report(admin, user_id: post.user_id)
|
||||||
|
expect(posts).to be_present
|
||||||
|
posts = FlagQuery.flagged_posts_report(admin, user_id: -1000)
|
||||||
|
expect(posts[0]).to be_blank
|
||||||
|
|
||||||
# chuck post in category a mod can not see and make sure its missing
|
# chuck post in category a mod can not see and make sure its missing
|
||||||
category = Fabricate(:category)
|
category = Fabricate(:category)
|
||||||
category.set_permissions(admins: :full)
|
category.set_permissions(admins: :full)
|
||||||
|
|
Loading…
Reference in New Issue