def report_abuse(self, id): """ When a user reports something as offensive, this action will mark it ready for moderation. If the user reporting is a system administrator it will be marked, but also made invisible so that it no longer shows up """ import ckan.model as model from ckanext.dgu.model.feedback import Feedback fb = Feedback.get(id) if fb: fb.moderated = False fb.moderation_required = True if is_sysadmin(): fb.visible = False flash_notice( "Queued. As you are an administrator, this item has been hidden" ) else: flash_notice( "Thank you for your feedback, the item has been queued for moderation" ) model.Session.add(fb) model.Session.commit() h.redirect_to(request.referer or '/data')
def report_abuse(self, id): """ When a user reports something as offensive, this action will mark it ready for moderation. If the user reporting is a system administrator it will be marked, but also made invisible so that it no longer shows up """ import ckan.model as model from ckanext.dgu.model.feedback import Feedback fb = Feedback.get(id) if fb: fb.moderated = False fb.moderation_required = True if is_sysadmin(): fb.visible = False flash_notice("Queued. As you are an administrator, this item has been hidden") else: flash_notice("Thank you for your feedback, the item has been queued for moderation") model.Session.add(fb) model.Session.commit() h.redirect_to(request.referer or '/data')
delete, publish, delete_and_ban within the action param """ import ckan.model as model from ckanext.dgu.model.feedback import Feedback, FeedbackBlockedUser def status(success, msg=''): return json.dumps({'success': success, 'message': msg}) # Only system administrators may access this page. try: context = {'model':model,'user': c.user} check_access('feedback_update',context) except NotAuthorized, e: return status('error', 'Permission denied') fb = Feedback.get(id) if not fb: return status('error', 'Feedback not found') action = request.params.get('action', '') if not action: return status('error', 'Unknown action') fb.moderated_by = c.user # Perform the relevant action based on what we have been asked to do. if action == 'delete': fb.active = False model.Session.add(fb) elif action == 'delete_and_ban': fb.active = False
delete, publish, delete_and_ban within the action param """ import ckan.model as model from ckanext.dgu.model.feedback import Feedback, FeedbackBlockedUser def status(success, msg=''): return json.dumps({'success': success, 'message': msg}) # Only system administrators may access this page. try: context = {'model': model, 'user': c.user} check_access('feedback_update', context) except NotAuthorized, e: return status('error', 'Permission denied') fb = Feedback.get(id) if not fb: return status('error', 'Feedback not found') action = request.params.get('action', '') if not action: return status('error', 'Unknown action') fb.moderated_by = c.user # Perform the relevant action based on what we have been asked to do. if action == 'delete': fb.active = False model.Session.add(fb) elif action == 'delete_and_ban': fb.active = False