def accept(cls, r, correct = True): ''' sets the various reporting fields, but does nothing to the corresponding spam fields (handled by unreport)''' amount = 1 if correct else -1 oldamount = int(r._name) # do nothing if nothing has changed if amount == oldamount: return up_change, down_change = score_changes(amount, oldamount) # update the user who made the report r._thing1._incr('report_correct', up_change) r._thing1._incr('report_ignored', down_change) # update the amount cls.set_amount(r, amount) # update the thing's number of reports only if we made no # decision prior to this if oldamount == 0: # update the author and thing field if getattr(r._thing2, Report._field) > 0: r._thing2._incr(Report._field, -1) aid = r._thing2.author_id author = Account._byID(aid) if getattr(author, Report._field) > 0: author._incr(Report._field, -1) admintools.report(r._thing2, -1)
def accept(cls, r, correct=True): ''' sets the various reporting fields, but does nothing to the corresponding spam fields (handled by unreport)''' amount = 1 if correct else -1 oldamount = int(r._name) # do nothing if nothing has changed if amount == oldamount: return up_change, down_change = score_changes(amount, oldamount) # update the user who made the report r._thing1._incr('report_correct', up_change) r._thing1._incr('report_ignored', down_change) # update the amount cls.set_amount(r, amount) # update the thing's number of reports only if we made no # decision prior to this if oldamount == 0: # update the author and thing field if getattr(r._thing2, Report._field) > 0: r._thing2._incr(Report._field, -1) if hasattr(r._thing2, "author_id"): aid = r._thing2.author_id author = Account._byID(aid) if getattr(author, Report._field) > 0: author._incr(Report._field, -1) admintools.report(r._thing2, -1)
def new(cls, user, thing): # check if this report exists already! rel = cls.rel(user, thing) oldreport = list( rel._query(rel.c._thing1_id == user._id, rel.c._thing2_id == thing._id, data=True)) # stop if we've seen this before, so that we never get the # same report from the same user twice if oldreport: return oldreport[0] r = Report(user, thing, '0', amount=0) if not thing._loaded: thing._load() # mark item as reported thing._incr(cls._field) # mark author as reported if hasattr(thing, 'author_id'): aid = thing.author_id author = Account._byID(aid) author._incr(cls._field) # mark user as having made a report user._incr('report_made') r._commit() admintools.report(thing) # if the thing is already marked as spam, accept the report if thing._spam: cls.accept(r) else: # set the report amount to 0, updating the cache in the process cls.set_amount(r, 0) return r
def new(cls, user, thing): # check if this report exists already! rel = cls.rel(user, thing) oldreport = list(rel._query(rel.c._thing1_id == user._id, rel.c._thing2_id == thing._id, data = True)) # stop if we've seen this before, so that we never get the # same report from the same user twice if oldreport: return oldreport[0] r = Report(user, thing, '0', amount = 0) if not thing._loaded: thing._load() # mark item as reported thing._incr(cls._field) # mark author as reported if hasattr(thing, 'author_id'): aid = thing.author_id author = Account._byID(aid) author._incr(cls._field) # mark user as having made a report user._incr('report_made') r._commit() admintools.report(thing) # if the thing is already marked as spam, accept the report if thing._spam: cls.accept(r) else: # set the report amount to 0, updating the cache in the process cls.set_amount(r, 0) return r