blob: a30fc3e3614576bdad2fcf133a4e8ec2dbfa9d87 [file] [log] [blame]
Copybara854996b2021-09-07 19:36:02 +00001# 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"""
8from __future__ import print_function
9from __future__ import division
10from __future__ import absolute_import
11
12import httplib
13import logging
14
15from framework import framework_helpers
16from framework import paginate
17from framework import permissions
18from framework import urls
19from framework import servlet
20from framework import template_helpers
21from framework import xsrf
22from tracker import spam_helpers
23from tracker import tracker_bizobj
24
25
26class 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 }