def onUpVoted(vote, post, user): vote.save() post.vote_up_count = int(post.vote_up_count) + 1 post.score = int(post.score) + 1 post.save() if not post.wiki: author = post.author if Repute.objects.get_reputation_by_upvoted_today(author) < int(REPUTATION_RULES["scope_per_day_by_upvotes"]): author.reputation = calculate_reputation(author.reputation, int(REPUTATION_RULES["gain_by_upvoted"])) author.save() question = post if ContentType.objects.get_for_model(post) == answer_type: question = post.question reputation = Repute( user=author, positive=int(REPUTATION_RULES["gain_by_upvoted"]), question=question, reputed_at=datetime.datetime.now(), reputation_type=1, reputation=author.reputation, ) reputation.save()
def onUpVotedCanceled(vote, post, user): vote.delete() post.vote_up_count = int(post.vote_up_count) - 1 if post.vote_up_count < 0: post.vote_up_count = 0 post.score = int(post.score) - 1 post.save() if not post.wiki: author = post.author author.reputation = calculate_reputation(author.reputation, int(REPUTATION_RULES["lose_by_upvote_canceled"])) author.save() question = post if ContentType.objects.get_for_model(post) == answer_type: question = post.question reputation = Repute( user=author, negative=int(REPUTATION_RULES["lose_by_upvote_canceled"]), question=question, reputed_at=datetime.datetime.now(), reputation_type=-8, reputation=author.reputation, ) reputation.save()
def onUpVoted(vote, post, user, timestamp=None): if timestamp is None: timestamp = datetime.datetime.now() vote.save() post.vote_up_count = int(post.vote_up_count) + 1 post.score = int(post.score) + 1 post.save() if not post.wiki: author = post.author todays_rep_gain = Repute.objects.get_reputation_by_upvoted_today(author) if todays_rep_gain < int(REPUTATION_RULES['scope_per_day_by_upvotes']): author.reputation = calculate_reputation(author.reputation, int(REPUTATION_RULES['gain_by_upvoted'])) author.save() question = post if isinstance(post, Answer): question = post.question reputation = Repute(user=author, positive=int(REPUTATION_RULES['gain_by_upvoted']), question=question, reputed_at=timestamp, reputation_type=1, reputation=author.reputation) reputation.save()
def onUpVotedCanceled(vote, post, user): vote.delete() post.decrement_vote_up_count() if post.vote_up_count < 0: post.vote_up_count = 0 post.score = int(post.score) - 1 post.save() if not post.wiki: author = post.author author.reputation = calculate_reputation(author.reputation, -int(settings.REP_LOST_BY_UPVOTE_CANCELED)) author.save() question = post if post.__class__ == Answer: question = post.question reputation = Repute(user=author, negative=-int(settings.REP_LOST_BY_UPVOTE_CANCELED), question=question, reputed_at=datetime.datetime.now(), reputation_type=-8, reputation=author.reputation) reputation.save()
def onUpVoted(vote, post, user): vote.save() post.increment_vote_up_count() post.score = int(post.score) + 1 post.save() if not post.wiki: author = post.author if Repute.objects.get_reputation_by_upvoted_today(author) < int(settings.MAX_REP_BY_UPVOTE_DAY): author.reputation = calculate_reputation(author.reputation, int(settings.REP_GAIN_BY_UPVOTED)) author.save() question = post if post.__class__ == Answer: question = post.question reputation = Repute(user=author, positive=int(settings.REP_GAIN_BY_UPVOTED), question=question, reputed_at=datetime.datetime.now(), reputation_type=1, reputation=author.reputation) reputation.save()
def onUpVotedCanceled(vote, post, user, timestamp=None): if timestamp is None: timestamp = datetime.datetime.now() vote.delete() post.vote_up_count = int(post.vote_up_count) - 1 if post.vote_up_count < 0: post.vote_up_count = 0 post.score = int(post.score) - 1 post.save() if not post.wiki: author = post.author author.reputation = calculate_reputation(author.reputation, int(REPUTATION_RULES['lose_by_upvote_canceled'])) author.save() question = post if isinstance(post, Answer): question = post.question reputation = Repute(user=author, negative=int(REPUTATION_RULES['lose_by_upvote_canceled']), question=question, reputed_at=timestamp, reputation_type=-8, reputation=author.reputation) reputation.save()
def onUpVoted(vote, post, user): vote.save() post.vote_up_count = int(post.vote_up_count) + 1 post.score = int(post.score) + 1 post.save() if not post.wiki: author = post.author if Repute.objects.get_reputation_by_upvoted_today(author) < int( REPUTATION_RULES['scope_per_day_by_upvotes']): author.reputation = calculate_reputation( author.reputation, int(REPUTATION_RULES['gain_by_upvoted'])) author.save() question = post if ContentType.objects.get_for_model(post) == answer_type: question = post.question reputation = Repute(user=author, positive=int( REPUTATION_RULES['gain_by_upvoted']), question=question, reputed_at=datetime.datetime.now(), reputation_type=1, reputation=author.reputation) reputation.save()
def onUpVotedCanceled(vote, post, user): vote.delete() post.vote_up_count = int(post.vote_up_count) - 1 if post.vote_up_count < 0: post.vote_up_count = 0 post.score = int(post.score) - 1 post.save() if not post.wiki: author = post.author author.reputation = calculate_reputation( author.reputation, int(REPUTATION_RULES['lose_by_upvote_canceled'])) author.save() question = post if ContentType.objects.get_for_model(post) == answer_type: question = post.question reputation = Repute(user=author, negative=int( REPUTATION_RULES['lose_by_upvote_canceled']), question=question, reputed_at=datetime.datetime.now(), reputation_type=-8, reputation=author.reputation) reputation.save()
def onFlaggedItem(item, post, user): item.save() post.offensive_flag_count = post.offensive_flag_count + 1 post.save() post.author.reputation = calculate_reputation(post.author.reputation, int(REPUTATION_RULES["lose_by_flagged"])) post.author.save() question = post if ContentType.objects.get_for_model(post) == answer_type: question = post.question reputation = Repute( user=post.author, negative=int(REPUTATION_RULES["lose_by_flagged"]), question=question, reputed_at=datetime.datetime.now(), reputation_type=-4, reputation=post.author.reputation, ) reputation.save() # todo: These should be updated to work on same revisions. if post.offensive_flag_count == VOTE_RULES["scope_flags_invisible_main_page"]: post.author.reputation = calculate_reputation( post.author.reputation, int(REPUTATION_RULES["lose_by_flagged_lastrevision_3_times"]) ) post.author.save() reputation = Repute( user=post.author, negative=int(REPUTATION_RULES["lose_by_flagged_lastrevision_3_times"]), question=question, reputed_at=datetime.datetime.now(), reputation_type=-6, reputation=post.author.reputation, ) reputation.save() elif post.offensive_flag_count == VOTE_RULES["scope_flags_delete_post"]: post.author.reputation = calculate_reputation( post.author.reputation, int(REPUTATION_RULES["lose_by_flagged_lastrevision_5_times"]) ) post.author.save() reputation = Repute( user=post.author, negative=int(REPUTATION_RULES["lose_by_flagged_lastrevision_5_times"]), question=question, reputed_at=datetime.datetime.now(), reputation_type=-7, reputation=post.author.reputation, ) reputation.save() post.deleted = True # post.deleted_at = datetime.datetime.now() # post.deleted_by = Admin post.save()
def onFlaggedItem(item, post, user, timestamp=None): if timestamp is None: timestamp = datetime.datetime.now() item.save() post.offensive_flag_count = post.offensive_flag_count + 1 post.save() post.author.reputation = calculate_reputation(post.author.reputation, int(REPUTATION_RULES['lose_by_flagged'])) post.author.save() question = post if isinstance(post, Answer): question = post.question reputation = Repute(user=post.author, negative=int(REPUTATION_RULES['lose_by_flagged']), question=question, reputed_at=timestamp, reputation_type=-4, reputation=post.author.reputation) reputation.save() #todo: These should be updated to work on same revisions. if post.offensive_flag_count == VOTE_RULES['scope_flags_invisible_main_page'] : post.author.reputation = calculate_reputation(post.author.reputation, int(REPUTATION_RULES['lose_by_flagged_lastrevision_3_times'])) post.author.save() reputation = Repute(user=post.author, negative=int(REPUTATION_RULES['lose_by_flagged_lastrevision_3_times']), question=question, reputed_at=timestamp, reputation_type=-6, reputation=post.author.reputation) reputation.save() elif post.offensive_flag_count == VOTE_RULES['scope_flags_delete_post']: post.author.reputation = calculate_reputation(post.author.reputation, int(REPUTATION_RULES['lose_by_flagged_lastrevision_5_times'])) post.author.save() reputation = Repute(user=post.author, negative=int(REPUTATION_RULES['lose_by_flagged_lastrevision_5_times']), question=question, reputed_at=timestamp, reputation_type=-7, reputation=post.author.reputation) reputation.save() post.deleted = True #post.deleted_at = timestamp #post.deleted_by = Admin post.save() mark_offensive.send( sender=post.__class__, instance=post, mark_by=user )
def onAnswerAcceptCanceled(answer, user): answer.accepted = False answer.accepted_at = None answer.question.answer_accepted = False answer.save() answer.question.save() answer.author.reputation = calculate_reputation( answer.author.reputation, int(REPUTATION_RULES['lose_by_accepted_answer_cancled'])) answer.author.save() reputation = Repute( user=answer.author, negative=int(REPUTATION_RULES['lose_by_accepted_answer_cancled']), question=answer.question, reputed_at=datetime.datetime.now(), reputation_type=-2, reputation=answer.author.reputation) reputation.save() user.reputation = calculate_reputation( user.reputation, int(REPUTATION_RULES['lose_by_canceling_accepted_answer'])) user.save() reputation = Repute( user=user, negative=int(REPUTATION_RULES['lose_by_canceling_accepted_answer']), question=answer.question, reputed_at=datetime.datetime.now(), reputation_type=-1, reputation=user.reputation) reputation.save()
def onAnswerAccept(answer, user): answer.accepted = True answer.accepted_at = datetime.datetime.now() answer.question.answer_accepted = True answer.save() answer.question.save() answer.author.reputation = calculate_reputation( answer.author.reputation, int(REPUTATION_RULES['gain_by_answer_accepted'])) answer.author.save() reputation = Repute(user=answer.author, positive=int( REPUTATION_RULES['gain_by_answer_accepted']), question=answer.question, reputed_at=datetime.datetime.now(), reputation_type=2, reputation=answer.author.reputation) reputation.save() user.reputation = calculate_reputation( user.reputation, int(REPUTATION_RULES['gain_by_accepting_answer'])) user.save() reputation = Repute(user=user, positive=int( REPUTATION_RULES['gain_by_accepting_answer']), question=answer.question, reputed_at=datetime.datetime.now(), reputation_type=3, reputation=user.reputation) reputation.save()
def onFlaggedItem(item, post, user): item.save() post.offensive_flag_count = post.offensive_flag_count + 1 post.save() post.author.reputation = calculate_reputation(post.author.reputation, -int(settings.REP_LOST_BY_FLAGGED)) post.author.save() question = post if post.__class__ == Answer: question = post.question reputation = Repute(user=post.author, negative=-int(settings.REP_LOST_BY_FLAGGED), question=question, reputed_at=datetime.datetime.now(), reputation_type=-4, reputation=post.author.reputation) reputation.save() #todo: These should be updated to work on same revisions. if post.offensive_flag_count == settings.FLAG_COUNT_TO_HIDE_POST : post.author.reputation = calculate_reputation(post.author.reputation, -int(settings.REP_LOST_BY_FLAGGED_3_TIMES)) post.author.save() reputation = Repute(user=post.author, negative=-int(settings.REP_LOST_BY_FLAGGED_3_TIMES), question=question, reputed_at=datetime.datetime.now(), reputation_type=-6, reputation=post.author.reputation) reputation.save() elif post.offensive_flag_count == settings.FLAG_COUNT_TO_DELETE_POST: post.author.reputation = calculate_reputation(post.author.reputation, -int(settings.REP_LOST_BY_FLAGGED_5_TIMES)) post.author.save() reputation = Repute(user=post.author, negative=-int(settings.REP_LOST_BY_FLAGGED_5_TIMES), question=question, reputed_at=datetime.datetime.now(), reputation_type=-7, reputation=post.author.reputation) reputation.save() post.deleted = True #post.deleted_at = datetime.datetime.now() #post.deleted_by = Admin post.save()
def onAnswerAcceptCanceled(answer, user): answer.accepted = False answer.accepted_at = None answer.question.answer_accepted = False answer.save() answer.question.save() answer.author.reputation = calculate_reputation(answer.author.reputation, -int(settings.REP_GAIN_BY_ACCEPTED_CANCELED)) answer.author.save() reputation = Repute(user=answer.author, negative=-int(settings.REP_GAIN_BY_ACCEPTED_CANCELED), question=answer.question, reputed_at=datetime.datetime.now(), reputation_type=-2, reputation=answer.author.reputation) reputation.save() user.reputation = calculate_reputation(user.reputation, -int(settings.REP_LOST_BY_CANCELING_ACCEPTED)) user.save() reputation = Repute(user=user, negative=-int(settings.REP_LOST_BY_CANCELING_ACCEPTED), question=answer.question, reputed_at=datetime.datetime.now(), reputation_type=-1, reputation=user.reputation) reputation.save()
def onAnswerAcceptCanceled(answer, user, timestamp=None): if timestamp is None: timestamp = datetime.datetime.now() answer.accepted = False answer.accepted_at = None answer.question.answer_accepted = False answer.save() answer.question.save() answer.author.reputation = calculate_reputation(answer.author.reputation, int(REPUTATION_RULES['lose_by_accepted_answer_cancled'])) answer.author.save() reputation = Repute(user=answer.author, negative=int(REPUTATION_RULES['lose_by_accepted_answer_cancled']), question=answer.question, reputed_at=timestamp, reputation_type=-2, reputation=answer.author.reputation) reputation.save() user.reputation = calculate_reputation(user.reputation, int(REPUTATION_RULES['lose_by_canceling_accepted_answer'])) user.save() reputation = Repute(user=user, negative=int(REPUTATION_RULES['lose_by_canceling_accepted_answer']), question=answer.question, reputed_at=timestamp, reputation_type=-1, reputation=user.reputation) reputation.save()
def onAnswerAccept(answer, user): answer.accepted = True answer.accepted_at = datetime.datetime.now() answer.question.answer_accepted = True answer.save() answer.question.save() answer.author.reputation = calculate_reputation( answer.author.reputation, int(REPUTATION_RULES["gain_by_answer_accepted"]) ) answer.author.save() reputation = Repute( user=answer.author, positive=int(REPUTATION_RULES["gain_by_answer_accepted"]), question=answer.question, reputed_at=datetime.datetime.now(), reputation_type=2, reputation=answer.author.reputation, ) reputation.save() user.reputation = calculate_reputation(user.reputation, int(REPUTATION_RULES["gain_by_accepting_answer"])) user.save() reputation = Repute( user=user, positive=int(REPUTATION_RULES["gain_by_accepting_answer"]), question=answer.question, reputed_at=datetime.datetime.now(), reputation_type=3, reputation=user.reputation, ) reputation.save()
def onAnswerAccept(answer, user, timestamp=None): if timestamp is None: timestamp = datetime.datetime.now() answer.accepted = True answer.accepted_at = timestamp answer.question.answer_accepted = True answer.save() answer.question.save() answer.author.reputation = calculate_reputation(answer.author.reputation, int(REPUTATION_RULES['gain_by_answer_accepted'])) answer.author.save() reputation = Repute(user=answer.author, positive=int(REPUTATION_RULES['gain_by_answer_accepted']), question=answer.question, reputed_at=timestamp, reputation_type=2, reputation=answer.author.reputation) reputation.save() user.reputation = calculate_reputation(user.reputation, int(REPUTATION_RULES['gain_by_accepting_answer'])) user.save() reputation = Repute(user=user, positive=int(REPUTATION_RULES['gain_by_accepting_answer']), question=answer.question, reputed_at=timestamp, reputation_type=3, reputation=user.reputation) reputation.save()
def onAnswerAccept(answer, user): answer.accepted = True answer.accepted_at = datetime.datetime.now() answer.question.answer_accepted = True answer.save() answer.question.save() answer.author.reputation = calculate_reputation(answer.author.reputation, int(settings.REP_GAIN_BY_ACCEPTED)) answer.author.save() reputation = Repute(user=answer.author, positive=int(settings.REP_GAIN_BY_ACCEPTED), question=answer.question, reputed_at=datetime.datetime.now(), reputation_type=2, reputation=answer.author.reputation) reputation.save() user.reputation = calculate_reputation(user.reputation, int(settings.REP_GAIN_BY_ACCEPTING)) user.save() reputation = Repute(user=user, positive=int(settings.REP_GAIN_BY_ACCEPTING), question=answer.question, reputed_at=datetime.datetime.now(), reputation_type=3, reputation=user.reputation) reputation.save()
def onDownVotedCanceled(vote, post, user): vote.delete() post.vote_down_count = int(post.vote_down_count) - 1 if post.vote_down_count < 0: post.vote_down_count = 0 post.score = post.score + 1 post.save() if not post.wiki: author = post.author author.reputation = calculate_reputation( author.reputation, int(REPUTATION_RULES['gain_by_downvote_canceled'])) author.save() question = post if ContentType.objects.get_for_model(post) == answer_type: question = post.question reputation = Repute(user=author, positive=int( REPUTATION_RULES['gain_by_downvote_canceled']), question=question, reputed_at=datetime.datetime.now(), reputation_type=4, reputation=author.reputation) reputation.save() user.reputation = calculate_reputation( user.reputation, int(REPUTATION_RULES['gain_by_canceling_downvote'])) user.save() reputation = Repute( user=user, positive=int(REPUTATION_RULES['gain_by_canceling_downvote']), question=question, reputed_at=datetime.datetime.now(), reputation_type=5, reputation=user.reputation) reputation.save()
def onDownVoted(vote, post, user): vote.save() post.vote_down_count = int(post.vote_down_count) + 1 post.score = int(post.score) - 1 post.save() if not post.wiki: author = post.author author.reputation = calculate_reputation( author.reputation, int(REPUTATION_RULES['lose_by_downvoted'])) author.save() question = post if ContentType.objects.get_for_model(post) == answer_type: question = post.question reputation = Repute(user=author, negative=int( REPUTATION_RULES['lose_by_downvoted']), question=question, reputed_at=datetime.datetime.now(), reputation_type=-3, reputation=author.reputation) reputation.save() user.reputation = calculate_reputation( user.reputation, int(REPUTATION_RULES['lose_by_downvoting'])) user.save() reputation = Repute(user=user, negative=int( REPUTATION_RULES['lose_by_downvoting']), question=question, reputed_at=datetime.datetime.now(), reputation_type=-5, reputation=user.reputation) reputation.save()
def onDownVotedCanceled(vote, post, user, timestamp=None): if timestamp is None: timestamp = datetime.datetime.now() vote.delete() post.vote_down_count = int(post.vote_down_count) - 1 if post.vote_down_count < 0: post.vote_down_count = 0 post.score = post.score + 1 post.save() if not post.wiki: author = post.author author.reputation = calculate_reputation(author.reputation, int(REPUTATION_RULES['gain_by_downvote_canceled'])) author.save() question = post if isinstance(post, Answer): question = post.question reputation = Repute(user=author, positive=int(REPUTATION_RULES['gain_by_downvote_canceled']), question=question, reputed_at=timestamp, reputation_type=4, reputation=author.reputation) reputation.save() user.reputation = calculate_reputation(user.reputation, int(REPUTATION_RULES['gain_by_canceling_downvote'])) user.save() reputation = Repute(user=user, positive=int(REPUTATION_RULES['gain_by_canceling_downvote']), question=question, reputed_at=timestamp, reputation_type=5, reputation=user.reputation) reputation.save()
def onDownVotedCanceled(vote, post, user): vote.delete() post.vote_down_count = int(post.vote_down_count) - 1 if post.vote_down_count < 0: post.vote_down_count = 0 post.score = post.score + 1 post.save() if not post.wiki: author = post.author author.reputation = calculate_reputation(author.reputation, int(REPUTATION_RULES["gain_by_downvote_canceled"])) author.save() question = post if ContentType.objects.get_for_model(post) == answer_type: question = post.question reputation = Repute( user=author, positive=int(REPUTATION_RULES["gain_by_downvote_canceled"]), question=question, reputed_at=datetime.datetime.now(), reputation_type=4, reputation=author.reputation, ) reputation.save() user.reputation = calculate_reputation(user.reputation, int(REPUTATION_RULES["gain_by_canceling_downvote"])) user.save() reputation = Repute( user=user, positive=int(REPUTATION_RULES["gain_by_canceling_downvote"]), question=question, reputed_at=datetime.datetime.now(), reputation_type=5, reputation=user.reputation, ) reputation.save()
def onDownVoted(vote, post, user, timestamp=None): if timestamp is None: timestamp = datetime.datetime.now() vote.save() post.vote_down_count = int(post.vote_down_count) + 1 post.score = int(post.score) - 1 post.save() if not post.wiki: author = post.author author.reputation = calculate_reputation(author.reputation, int(REPUTATION_RULES['lose_by_downvoted'])) author.save() question = post if isinstance(post, Answer): question = post.question reputation = Repute(user=author, negative=int(REPUTATION_RULES['lose_by_downvoted']), question=question, reputed_at=timestamp, reputation_type=-3, reputation=author.reputation) reputation.save() user.reputation = calculate_reputation(user.reputation, int(REPUTATION_RULES['lose_by_downvoting'])) user.save() reputation = Repute(user=user, negative=int(REPUTATION_RULES['lose_by_downvoting']), question=question, reputed_at=timestamp, reputation_type=-5, reputation=user.reputation) reputation.save()
def onDownVotedCanceled(vote, post, user): vote.delete() post.vote_down_count = int(post.vote_down_count) - 1 if post.vote_down_count < 0: post.vote_down_count = 0 post.score = post.score + 1 post.save() if not post.wiki: author = post.author author.reputation = calculate_reputation(author.reputation, int(settings.REP_GAIN_BY_DOWNVOTE_CANCELED)) author.save() question = post if post.__class__ == Answer: question = post.question reputation = Repute(user=author, positive=int(settings.REP_GAIN_BY_DOWNVOTE_CANCELED), question=question, reputed_at=datetime.datetime.now(), reputation_type=4, reputation=author.reputation) reputation.save() user.reputation = calculate_reputation(user.reputation, int(settings.REP_GAIN_BY_CANCELING_DOWNVOTE)) user.save() reputation = Repute(user=user, positive=int(settings.REP_GAIN_BY_CANCELING_DOWNVOTE), question=question, reputed_at=datetime.datetime.now(), reputation_type=5, reputation=user.reputation) reputation.save()
def onDownVoted(vote, post, user): vote.save() post.vote_down_count = int(post.vote_down_count) + 1 post.score = int(post.score) - 1 post.save() if not post.wiki: author = post.author author.reputation = calculate_reputation(author.reputation, int(REPUTATION_RULES["lose_by_downvoted"])) author.save() question = post if ContentType.objects.get_for_model(post) == answer_type: question = post.question reputation = Repute( user=author, negative=int(REPUTATION_RULES["lose_by_downvoted"]), question=question, reputed_at=datetime.datetime.now(), reputation_type=-3, reputation=author.reputation, ) reputation.save() user.reputation = calculate_reputation(user.reputation, int(REPUTATION_RULES["lose_by_downvoting"])) user.save() reputation = Repute( user=user, negative=int(REPUTATION_RULES["lose_by_downvoting"]), question=question, reputed_at=datetime.datetime.now(), reputation_type=-5, reputation=user.reputation, ) reputation.save()
def onDownVoted(vote, post, user): vote.save() post.vote_down_count = int(post.vote_down_count) + 1 post.score = int(post.score) - 1 post.save() if not post.wiki: author = post.author author.reputation = calculate_reputation(author.reputation, -int(settings.REP_LOST_BY_DOWNVOTED)) author.save() question = post if post.__class__ == Answer: question = post.question reputation = Repute(user=author, negative=-int(settings.REP_LOST_BY_DOWNVOTED), question=question, reputed_at=datetime.datetime.now(), reputation_type=-3, reputation=author.reputation) reputation.save() user.reputation = calculate_reputation(user.reputation, -int(settings.REP_LOST_BY_DOWNVOTING)) user.save() reputation = Repute(user=user, negative=-int(settings.REP_LOST_BY_DOWNVOTING), question=question, reputed_at=datetime.datetime.now(), reputation_type=-5, reputation=user.reputation) reputation.save()
def onFlaggedItem(item, post, user): item.save() post.offensive_flag_count = post.offensive_flag_count + 1 post.save() post.author.reputation = calculate_reputation( post.author.reputation, int(REPUTATION_RULES['lose_by_flagged'])) post.author.save() question = post if ContentType.objects.get_for_model(post) == answer_type: question = post.question reputation = Repute(user=post.author, negative=int(REPUTATION_RULES['lose_by_flagged']), question=question, reputed_at=datetime.datetime.now(), reputation_type=-4, reputation=post.author.reputation) reputation.save() #todo: These should be updated to work on same revisions. if post.offensive_flag_count == VOTE_RULES[ 'scope_flags_invisible_main_page']: post.author.reputation = calculate_reputation( post.author.reputation, int(REPUTATION_RULES['lose_by_flagged_lastrevision_3_times'])) post.author.save() reputation = Repute( user=post.author, negative=int( REPUTATION_RULES['lose_by_flagged_lastrevision_3_times']), question=question, reputed_at=datetime.datetime.now(), reputation_type=-6, reputation=post.author.reputation) reputation.save() elif post.offensive_flag_count == VOTE_RULES['scope_flags_delete_post']: post.author.reputation = calculate_reputation( post.author.reputation, int(REPUTATION_RULES['lose_by_flagged_lastrevision_5_times'])) post.author.save() reputation = Repute( user=post.author, negative=int( REPUTATION_RULES['lose_by_flagged_lastrevision_5_times']), question=question, reputed_at=datetime.datetime.now(), reputation_type=-7, reputation=post.author.reputation) reputation.save() post.deleted = True #post.deleted_at = datetime.datetime.now() #post.deleted_by = Admin post.save()