mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-12 13:24:52 +00:00
Illegal report by react (#3415)
* illegal report 1, add illegal report at shared file page 2, list all illegal reports at admin page * add ENABLE_SHARE_LINK_REPORT_ILLEGAL setting * UserRateThrottle -> AnonRateThrottle * use to_python_boolean * frontend by React * remove illegal report dialog in shared dir view * add migrations dir * add illegal_reports migrations * rename illegal to abuse in api * rename illegal to abuse in test * rename illegal to abuse in share file view * rename illegal to abuse in react * rename illegal to abuse in Backbone * add enableShareLinkReportAbuse in templates * add ReportAbuse * update ReportAbuse * update ReportAbuse urls * update ReportAbuse api-js * sysadmin_react_app.html * sysadmin.py * fix * fix * fix * can not abuse own file * Contact Information is required. * fix review * remove repo icon
This commit is contained in:
89
static/scripts/sysadmin-app/views/abuse-report.js
Normal file
89
static/scripts/sysadmin-app/views/abuse-report.js
Normal file
@@ -0,0 +1,89 @@
|
||||
define([
|
||||
'jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'common',
|
||||
'moment',
|
||||
'app/views/widgets/hl-item-view'
|
||||
], function($, _, Backbone, Common, Moment, HLItemView) {
|
||||
'use strict';
|
||||
|
||||
var AbuseReportView = HLItemView.extend({
|
||||
tagName: 'tr',
|
||||
|
||||
template: _.template($('#abuse-report-item-tmpl').html()),
|
||||
|
||||
events: {
|
||||
'click .abuse-report-handle': 'handleReport'
|
||||
},
|
||||
|
||||
initialize: function() {
|
||||
HLItemView.prototype.initialize.call(this);
|
||||
this.listenTo(this.model, "change", this.render);
|
||||
},
|
||||
|
||||
render: function() {
|
||||
var data = this.model.toJSON(), abuse_type_output,
|
||||
icon_size = Common.isHiDPI() ? 48 : 24,
|
||||
icon_url = this.model.getIconUrl(icon_size),
|
||||
time = Moment(data['time']);
|
||||
|
||||
if (data['abuse_type'] == 'copyright') {
|
||||
abuse_type_output = gettext('Copyright infringement');
|
||||
} else if (data['abuse_type'] == 'virus') {
|
||||
abuse_type_output = gettext('Virus');
|
||||
} else if (data['abuse_type'] == 'abuse_content') {
|
||||
abuse_type_output = gettext('Abuse content');
|
||||
} else if (data['abuse_type'] == 'other') {
|
||||
abuse_type_output = gettext('Other');
|
||||
}
|
||||
|
||||
data['time'] = time.format('LLLL');
|
||||
data['time_from_now'] = Common.getRelativeTimeStr(time);
|
||||
data['icon_url'] = icon_url;
|
||||
data['abuse_type_output'] = abuse_type_output;
|
||||
|
||||
this.$el.html(this.template(data));
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
handleReport: function() {
|
||||
var _this = this, handled_parameter,
|
||||
report_id = this.model.get('id'),
|
||||
handled = this.model.get('handled');
|
||||
|
||||
if (handled) {
|
||||
handled_parameter = false;
|
||||
} else {
|
||||
handled_parameter = true;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: Common.getUrl({
|
||||
'name':'admin-abuse-report',
|
||||
'report_id': report_id
|
||||
}),
|
||||
type: 'PUT',
|
||||
cache: false,
|
||||
beforeSend: Common.prepareCSRFToken,
|
||||
dataType: 'json',
|
||||
data: {
|
||||
'handled': handled_parameter
|
||||
},
|
||||
success: function() {
|
||||
_this.model.set({'handled': handled_parameter});
|
||||
Common.feedback(gettext("Successfully change the report's status."), 'success');
|
||||
},
|
||||
error: function(xhr, textStatus, errorThrown) {
|
||||
Common.ajaxErrorHandler(xhr, textStatus, errorThrown);
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
return AbuseReportView;
|
||||
});
|
87
static/scripts/sysadmin-app/views/abuse-reports.js
Normal file
87
static/scripts/sysadmin-app/views/abuse-reports.js
Normal file
@@ -0,0 +1,87 @@
|
||||
define([
|
||||
'jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'common',
|
||||
'sysadmin-app/views/abuse-report',
|
||||
'sysadmin-app/collection/abuse-reports'
|
||||
], function($, _, Backbone, Common, AbuseReportView, AbuseReportsCollection) {
|
||||
'use strict';
|
||||
|
||||
var AbuseReportsView = Backbone.View.extend({
|
||||
|
||||
id: 'admin-abuse-reports',
|
||||
|
||||
template: _.template($("#abuse-reports-tmpl").html()),
|
||||
|
||||
initialize: function() {
|
||||
this.abuseReportsCollection = new AbuseReportsCollection();
|
||||
this.listenTo(this.abuseReportsCollection, 'add', this.addOne);
|
||||
this.listenTo(this.abuseReportsCollection, 'reset', this.reset);
|
||||
this.render();
|
||||
},
|
||||
|
||||
render: function() {
|
||||
this.$el.html(this.template());
|
||||
|
||||
this.$table = this.$('table');
|
||||
this.$tableBody = $('tbody', this.$table);
|
||||
this.$loadingTip = this.$('.loading-tip');
|
||||
this.$emptyTip = this.$('.empty-tips');
|
||||
this.$error = this.$('.error');
|
||||
},
|
||||
|
||||
initPage: function() {
|
||||
this.$loadingTip.show();
|
||||
this.$table.hide();
|
||||
this.$tableBody.empty();
|
||||
this.$emptyTip.hide();
|
||||
this.$error.hide();
|
||||
},
|
||||
|
||||
hide: function() {
|
||||
this.$el.detach();
|
||||
this.attached = false;
|
||||
},
|
||||
|
||||
show: function() {
|
||||
if (!this.attached) {
|
||||
this.attached = true;
|
||||
$("#right-panel").html(this.$el);
|
||||
}
|
||||
this.getContent();
|
||||
},
|
||||
|
||||
getContent: function() {
|
||||
this.initPage();
|
||||
var _this = this;
|
||||
|
||||
this.abuseReportsCollection.fetch({
|
||||
cache: false,
|
||||
reset: true,
|
||||
error: function(collection, response, opts) {
|
||||
var err_msg = Common.prepareCollectionFetchErrorMsg(collection, response, opts);
|
||||
_this.$error.html(err_msg).show();
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
addOne: function(report) {
|
||||
var view = new AbuseReportView({model: report});
|
||||
this.$tableBody.append(view.render().el);
|
||||
},
|
||||
|
||||
reset: function() {
|
||||
this.initPage();
|
||||
|
||||
this.$loadingTip.hide();
|
||||
if (this.abuseReportsCollection.length > 0) {
|
||||
this.abuseReportsCollection.each(this.addOne, this);
|
||||
this.$table.show();
|
||||
} else {
|
||||
this.$emptyTip.show();
|
||||
}
|
||||
}
|
||||
});
|
||||
return AbuseReportsView;
|
||||
});
|
Reference in New Issue
Block a user