当前位置: 首页>>代码示例>>Python>>正文


Python models.Repute类代码示例

本文整理汇总了Python中models.Repute的典型用法代码示例。如果您正苦于以下问题:Python Repute类的具体用法?Python Repute怎么用?Python Repute使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Repute类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: onUpVoted

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()
开发者ID:hifans,项目名称:CNPROG,代码行数:26,代码来源:auth.py

示例2: onUpVotedCanceled

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()
开发者ID:hifans,项目名称:CNPROG,代码行数:27,代码来源:auth.py

示例3: onUpVotedCanceled

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()
开发者ID:EzerchE,项目名称:askbot-devel,代码行数:28,代码来源:auth.py

示例4: onUpVoted

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()
开发者ID:EzerchE,项目名称:askbot-devel,代码行数:28,代码来源:auth.py

示例5: onUpVotedCanceled

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()
开发者ID:cloudbring,项目名称:osqa,代码行数:26,代码来源:auth.py

示例6: onUpVoted

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()
开发者ID:cloudbring,项目名称:osqa,代码行数:25,代码来源:auth.py

示例7: onFlaggedItem

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()
开发者ID:badri,项目名称:xwordclub,代码行数:60,代码来源:auth.py

示例8: onFlaggedItem

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
        )
开发者ID:EzerchE,项目名称:askbot-devel,代码行数:59,代码来源:auth.py

示例9: onFlaggedItem

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()
开发者ID:cloudbring,项目名称:osqa,代码行数:52,代码来源:auth.py

示例10: onAnswerAccept

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()
开发者ID:cloudbring,项目名称:osqa,代码行数:28,代码来源:auth.py

示例11: onAnswerAcceptCanceled

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()
开发者ID:cloudbring,项目名称:osqa,代码行数:28,代码来源:auth.py

示例12: onAnswerAccept

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()
开发者ID:badri,项目名称:xwordclub,代码行数:32,代码来源:auth.py

示例13: onAnswerAcceptCanceled

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()
开发者ID:EzerchE,项目名称:askbot-devel,代码行数:30,代码来源:auth.py

示例14: onAnswerAccept

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()
开发者ID:EzerchE,项目名称:askbot-devel,代码行数:31,代码来源:auth.py

示例15: onDownVotedCanceled

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()
开发者ID:EzerchE,项目名称:askbot-devel,代码行数:40,代码来源:auth.py


注:本文中的models.Repute类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。