Beispiel #1
0
def add_points_remove_comment(user,
                              point_event,
                              timestamp=None,
                              comment_date=None,
                              comment_id=None,
                              **kwargs):
    from eureka.domain.models import PointData

    # TODO: implement the limit to 15 points per day per user
    # Feature: limit to 15 points per day and per user for comments
    #   (see comments for the ADD_COMMENT event handling)
    assert comment_date is not None

    # Try to find the added points when the comment was created
    pd = PointData.get_by(label=PointCategory.ADD_COMMENT,
                          subject_id=comment_id)
    if pd is not None:
        points_removed = -pd.nb_points

    # Keep the old mechanism
    elif _remove_comment_event_should_remove_some_points(user, timestamp):
        points_removed = -_comment_points_by_date(comment_date)
    else:
        points_removed = 0

    reason = kwargs.get('reason', '')
    user.add_points(PointCategory.REMOVE_COMMENT,
                    nb_points=points_removed,
                    reason=reason,
                    timestamp=timestamp,
                    subject_id=comment_id)
Beispiel #2
0
def add_points_remove_comment(user, point_event, timestamp=None,
                              comment_date=None, comment_id=None, **kwargs):
    from eureka.domain.models import PointData

    # TODO: implement the limit to 15 points per day per user
    # Feature: limit to 15 points per day and per user for comments
    #   (see comments for the ADD_COMMENT event handling)
    assert comment_date is not None

    # Try to find the added points when the comment was created
    pd = PointData.get_by(
        label=PointCategory.ADD_COMMENT,
        subject_id=comment_id
    )
    if pd is not None:
        points_removed = -pd.nb_points

    # Keep the old mechanism
    elif _remove_comment_event_should_remove_some_points(user, timestamp):
        points_removed = -_comment_points_by_date(comment_date)
    else:
        points_removed = 0

    reason = kwargs.get('reason', '')
    user.add_points(
        PointCategory.REMOVE_COMMENT,
        nb_points=points_removed,
        reason=reason,
        timestamp=timestamp,
        subject_id=comment_id
    )
Beispiel #3
0
 def remove_point(self, point_id):
     PointData.get(point_id).delete()
     flashmessage.set_flash(_(u"Points deleted"))