Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added post moderation buttons in SPV
- Loading branch information
Showing
12 changed files
with
226 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
app/assets/javascripts/app/views/single-post-viewer/single_post_moderation.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
app.views.SinglePostModeration = app.views.Feedback.extend({ | ||
templateName: "single-post-viewer/single-post-moderation", | ||
|
||
events: function() { | ||
return _.defaults({ | ||
"click .remove_post": "destroyModel", | ||
}, app.views.Feedback.prototype.events); | ||
}, | ||
|
||
presenter: function() { | ||
var interactions = this.model.interactions; | ||
|
||
return _.extend(this.defaultPresenter(), { | ||
authorIsCurrentUser : this.authorIsCurrentUser(), | ||
}); | ||
}, | ||
|
||
renderPluginWidgets : function() { | ||
app.views.Base.prototype.renderPluginWidgets.apply(this); | ||
this.$('a').tooltip({placement: 'bottom'}); | ||
}, | ||
|
||
authorIsCurrentUser: function() { | ||
return app.currentUser.authenticated() && this.model.get("author").id == app.user().id; | ||
}, | ||
|
||
destroyModel: function(evt) { | ||
if(evt) { evt.preventDefault(); } | ||
var url = this.model.urlRoot + '/' + this.model.id; | ||
|
||
if (confirm(Diaspora.I18n.t("remove_post"))) { | ||
this.model.destroy({ url: url }) | ||
.done(function() { | ||
// return to stream | ||
document.location.href = "/stream"; | ||
}) | ||
.fail(function() { | ||
var flash = new Diaspora.Widgets.FlashMessages; | ||
flash.render({ | ||
success: false, | ||
notice: Diaspora.I18n.t('failed_to_remove') | ||
}); | ||
}); | ||
} | ||
} | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
app/assets/templates/single-post-viewer/single-post-moderation_tpl.jst.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<div> | ||
{{#if loggedIn}} | ||
{{#if authorIsCurrentUser}} | ||
<a href="#" class="remove_post" title="{{t "delete"}}"> | ||
<i class="entypo gray cross"></i> | ||
</a> | ||
{{else}} | ||
<a href="#" data-type="post" class="post_report" title="{{t "report.name"}}"> | ||
<i class="entypo gray">!</i> | ||
</a> | ||
<a href="#" data-type="post" class="block_user" title="{{t "ignore"}}"> | ||
<i class="entypo gray">🚫</i> | ||
</a> | ||
<a href="#" data-type="post" class="hide_post" title="{{t "stream.hide"}}"> | ||
<i class="entypo gray cross"></i> | ||
</a> | ||
{{/if}} | ||
{{/if}} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
@javascript | ||
Feature: using SPV moderation buttons | ||
|
||
Background: | ||
Given following users exist: | ||
| username | | ||
| bob | | ||
| alice | | ||
And I sign in as "bob@bob.bob" | ||
And a user with username "bob" is connected with "alice" | ||
And I am on the home page | ||
|
||
Scenario: hide a contact's post | ||
Given I expand the publisher | ||
When I write the status message "Here is a post to test with" | ||
And I submit the publisher | ||
|
||
And I log out | ||
And I sign in as "alice@alice.alice" | ||
|
||
And I open the show page of the "Here is a post to test with" post | ||
And I click to hide the post | ||
And I confirm the alert | ||
|
||
Then I should be on the stream page | ||
|
||
Scenario: block a contact | ||
Given I expand the publisher | ||
When I write the status message "Here is a post to test with" | ||
And I submit the publisher | ||
|
||
And I log out | ||
And I sign in as "alice@alice.alice" | ||
|
||
And I open the show page of the "Here is a post to test with" post | ||
And I click to block the user | ||
And I confirm the alert | ||
|
||
Then I should be on the stream page | ||
|
||
Scenario: report a contact | ||
Given I expand the publisher | ||
When I write the status message "Here is a post to test with" | ||
And I submit the publisher | ||
|
||
And I log out | ||
And I sign in as "alice@alice.alice" | ||
|
||
And I open the show page of the "Here is a post to test with" post | ||
And I click to report the post | ||
And I confirm the alert | ||
|
||
And I should see a flash message containing "The report was successfully created" | ||
|
||
Scenario: delete own post | ||
Given I expand the publisher | ||
When I write the status message "Here is a post to test with" | ||
And I submit the publisher | ||
|
||
And I open the show page of the "Here is a post to test with" post | ||
And I click to delete the post | ||
And I confirm the alert | ||
|
||
Then I should be on the stream page | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
And /^I click to hide the post/ do | ||
find('.hide_post').click | ||
end | ||
|
||
And /^I click to block the user/ do | ||
find('.block_user').click | ||
end | ||
|
||
And /^I click to report the post/ do | ||
find('.post_report').click | ||
end | ||
|
||
And /^I click to delete the post/ do | ||
find('.remove_post').click | ||
end |