Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 1 | # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 | # Use of this source code is governed by a BSD-style |
| 3 | # license that can be found in the LICENSE file or at |
| 4 | # https://developers.google.com/open-source/licenses/bsd |
| 5 | |
| 6 | """Classes that implement spam flagging features. |
| 7 | """ |
| 8 | from __future__ import print_function |
| 9 | from __future__ import division |
| 10 | from __future__ import absolute_import |
| 11 | |
| 12 | import httplib |
| 13 | import logging |
| 14 | |
| 15 | from framework import framework_helpers |
| 16 | from framework import paginate |
| 17 | from framework import permissions |
| 18 | from framework import urls |
| 19 | from framework import servlet |
| 20 | from framework import template_helpers |
| 21 | from framework import xsrf |
| 22 | from tracker import spam_helpers |
| 23 | from tracker import tracker_bizobj |
| 24 | |
| 25 | |
| 26 | class ModerationQueue(servlet.Servlet): |
| 27 | _PAGE_TEMPLATE = 'tracker/spam-moderation-queue.ezt' |
| 28 | |
| 29 | def GatherPageData(self, mr): |
| 30 | if not self.CheckPerm(mr, permissions.MODERATE_SPAM): |
| 31 | raise permissions.PermissionException() |
| 32 | |
| 33 | page_perms = self.MakePagePerms( |
| 34 | mr, None, permissions.MODERATE_SPAM, |
| 35 | permissions.EDIT_ISSUE, permissions.CREATE_ISSUE, |
| 36 | permissions.SET_STAR) |
| 37 | |
| 38 | # TODO(seanmccullough): Figure out how to get the IssueFlagQueue either |
| 39 | # integrated into this page data, or on its own subtab of spam moderation. |
| 40 | # Also figure out the same for Comments. |
| 41 | issue_items, total_count = self.services.spam.GetIssueClassifierQueue( |
| 42 | mr.cnxn, self.services.issue, mr.project.project_id, mr.start, mr.num) |
| 43 | |
| 44 | issue_queue = spam_helpers.DecorateIssueClassifierQueue(mr.cnxn, |
| 45 | self.services.issue, self.services.spam, self.services.user, |
| 46 | issue_items) |
| 47 | |
| 48 | url_params = [(name, mr.GetParam(name)) for name in |
| 49 | framework_helpers.RECOGNIZED_PARAMS] |
| 50 | p = paginate.ArtifactPagination( |
| 51 | [], mr.num, mr.GetPositiveIntParam('start'), |
| 52 | mr.project_name, urls.SPAM_MODERATION_QUEUE, total_count=total_count, |
| 53 | url_params=url_params) |
| 54 | |
| 55 | return { |
| 56 | 'issue_queue': issue_queue, |
| 57 | 'projectname': mr.project.project_name, |
| 58 | 'pagination': p, |
| 59 | 'page_perms': page_perms, |
| 60 | } |