Skip to content
This repository
Browse code

Remove things as spam or not spam.

  • Loading branch information...
commit 2a8876bfb6dd2700ab497411720360a2f215c08e 1 parent 1088fe7
Brian Simpson authored February 24, 2012
28  r2/r2/controllers/api.py
@@ -1426,19 +1426,27 @@ def POST_searchfeedback(self, q, sort, t, approval):
1426 1426
 
1427 1427
     @noresponse(VUser(), VModhash(),
1428 1428
                 why = VSrCanBan('id'),
1429  
-                thing = VByName('id'))
1430  
-    def POST_remove(self, why, thing):
  1429
+                thing = VByName('id'),
  1430
+                spam = VBoolean('spam', default=True))
  1431
+    def POST_remove(self, why, thing, spam):
1431 1432
         if getattr(thing, "promoted", None) is None:
1432 1433
             end_trial(thing, why + "-removed")
1433  
-            kw = {}
1434  
-            if thing._spam:
  1434
+
  1435
+            kw = {'target': thing}
  1436
+            if thing._spam and spam:
1435 1437
                 kw['details'] = 'confirm_spam'
1436  
-            admintools.spam(thing, False, not c.user_is_admin, c.user.name)
1437  
-            sr = thing.subreddit_slow
1438  
-            if isinstance(thing, Link):
1439  
-                ModAction.create(sr, c.user, 'removelink', target=thing, **kw)
1440  
-            elif isinstance(thing, Comment):
1441  
-                ModAction.create(sr, c.user, 'removecomment', target=thing, **kw)
  1438
+
  1439
+            admintools.spam(thing, auto=False,
  1440
+                            moderator_banned=not c.user_is_admin,
  1441
+                            banner=c.user.name,
  1442
+                            train_spam=spam)
  1443
+
  1444
+            if isinstance(thing, (Link, Comment)):
  1445
+                if not spam:
  1446
+                    kw['details'] = 'not_spam'
  1447
+                sr = thing.subreddit_slow
  1448
+                action = 'remove' + thing.__class__.__name__.lower()
  1449
+                ModAction.create(sr, c.user, action, **kw)
1442 1450
 
1443 1451
     @noresponse(VUser(), VModhash(),
1444 1452
                 why = VSrCanBan('id'),
4  r2/r2/models/admintools.py
@@ -32,7 +32,7 @@
32 32
 class AdminTools(object):
33 33
 
34 34
     def spam(self, things, auto=True, moderator_banned=False,
35  
-             banner=None, date = None, **kw):
  35
+             banner=None, date=None, train_spam=True, **kw):
36 36
         from r2.lib.db import queries
37 37
 
38 38
         all_things = tup(things)
@@ -58,6 +58,8 @@ def spam(self, things, auto=True, moderator_banned=False,
58 58
             else:
59 59
                 ban_info['banner'] = banner
60 60
 
  61
+            ban_info['not_spam'] = not train_spam
  62
+
61 63
             t.ban_info = ban_info
62 64
             t._commit()
63 65
 
2  r2/r2/models/builder.py
@@ -238,6 +238,8 @@ def wrap_items(self, items):
238 238
                     w.moderator_banned = ban_info.get('moderator_banned', False)
239 239
                     w.autobanned = ban_info.get('auto', False)
240 240
                     w.banner = ban_info.get('banner')
  241
+                    if ban_info.get('not_spam', False) and w.banner:
  242
+                        w.banner += ' (not spam)'
241 243
                     w.use_big_modbuttons = True
242 244
                     if getattr(w, "author", None) and w.author._spam:
243 245
                         w.show_spam = "author"
1  r2/r2/models/modaction.py
@@ -62,6 +62,7 @@ class ModAction(tdb_cassandra.UuidThing, Printable):
62 62
                      'unspam': _('unspam'),
63 63
                      # remove comment/link
64 64
                      'confirm_spam': _('confirmed spam'),
  65
+                     'not_spam': _('not spam'),
65 66
                      # removemoderator
66 67
                      'remove_self': _('removed self'),
67 68
                      # editsettings
5  r2/r2/templates/printablebuttons.html
@@ -41,7 +41,10 @@
41 41
     %if not getattr(thing.thing, "use_big_modbuttons", False):
42 42
       %if not thing.show_spam:
43 43
         <li>
44  
-           ${ynbutton(_("remove"), _("removed"), "remove")}
  44
+           ${ynbutton(_("spam"), _("spammed"), "remove")}
  45
+        </li>
  46
+        <li>
  47
+           ${ynbutton(_("remove"), _("removed"), "remove", hidden_data=dict(spam=False))}
45 48
         </li>
46 49
       %endif
47 50
 

0 notes on commit 2a8876b

Please sign in to comment.
Something went wrong with that request. Please try again.