Beispiel #1
0
    def save_reply(cls, user, snippet_id, comment_id, comment_text):
        """
        Save user comments for the post in database
        """
        from badges import Badge, UserBadge
        if Snippet.objects.filter(id=snippet_id).update(
                comments_count=F('comments_count') + 1) == 1:
            UserGraph.objects.filter(user=user).update(
                comments_count=F('comments_count') + 1)
            cls.objects.filter(id=comment_id).update(
                replies_count=F('replies_count') + 1)
            comment = cls.objects.create(snippet_id=snippet_id,
                                         reply_to_id=comment_id,
                                         user=user,
                                         comment_text=comment_text,
                                         updated_by=str(user),
                                         created_by=str(user))

            if not UserBadge.objects.filter(user=user, badge=Badge.get_commentator()).exists() \
            and UserGraph.objects.filter(user=user, comments_count__gte=10).exists():
                # User earned a commentator badge
                UserBadge.award(user, Badge.get_commentator())

            #Message.add_reply_msg(comment, user)
            return comment
    def __init__(self):
        Badge.__init__(self)
        self.description = "Moderator"
        self.badge_category = BadgeCategory.SILVER
        self.points = 0

        # Hidden badge
        self.is_hidden_if_unknown = True
Beispiel #3
0
    def __init__(self, custom_badge_type):
        Badge.__init__(self)
        self.is_hidden_if_unknown = True

        self.name = custom_badge_type.key().name()
        self.description = custom_badge_type.description
        self.full_description = custom_badge_type.full_description
        self.points = custom_badge_type.points
        self.badge_category = custom_badge_type.category
        self.custom_icon_src = custom_badge_type.icon_src
    def __init__(self, badge_type):
        Badge.__init__(self)

        # Set topic-specific properties
        self.topic_standalone_title = badge_type.topic_standalone_title
        self.exercise_names_required = badge_type.exercise_names_required

        # Set typical badge properties
        self.name = TopicExerciseBadge.name_for_topic_key_name(
            badge_type.topic_key_name)
        self.description = self.topic_standalone_title
        self.points = 0
        self.badge_category = BadgeCategory.MASTER
        self.is_retired = badge_type.retired
        self.is_hidden_if_unknown = self.is_retired
Beispiel #5
0
 def sign_up(cls, username, email, password, gender, hometown=None, location=None, locale=None, has_fb_account=False, is_verified=False):
     """
     Creates a new non-admin user in database 
     """
     from badges import Badge, UserBadge
            
     try:
         user = cls.objects.get(Q(username=username) | Q(email=email))
         if user.username == username:
             raise HunkitError('Username "%s" already registered with us, if you forgotten your password? <a href="%s">Request new one</a> or choose a different username.' % (username, reverse('app_forgot_password')))
         
         raise HunkitError('Its seems to be that you are already registered with this email address, if you forgotten your password? <a href="%s">Request new one.</a>' % reverse('app_forgot_password'))            
     except cls.DoesNotExist:
                     
         verification_code = None
         if not is_verified:
             verification_code = _random_digest()
         
         if hometown:
             hometown = Location.get_or_create(hometown, username)
         
         if location:
             location = Location.get_or_create(location, username)
             
         user = cls.objects.create_user(username=username,
                                        email=email,
                                        password=password,
                                        gender= gender,
                                        hometown=hometown,
                                        location=location,
                                        locale=locale,
                                        is_verified=is_verified,
                                        verification_code=verification_code,
                                        has_fb_account=has_fb_account,
                                        updated_by=username,
                                        created_by=username)
         
         UserGraph.objects.create(user=user, created_by=username)
         
         # Create subscriptions to default languages
         langs = []
         for lang in Language.objects.filter(is_default=True):
             langs.append(lang.id)
             Subscription.objects.create(user=user,language=lang, created_by=username)
         
         if langs:
             LanguageGraph.objects.filter(language_id__in=langs).update(readers_count=F('readers_count') + 1)
             
         # Awarding Freshman badge
         UserBadge.award(user, Badge.get_freshman())
             
         return user
Beispiel #6
0
 def __init__(self):
     Badge.__init__(self)
     self.description = "" + u"בטא את עצמך"
     self.badge_category = BadgeCategory.BRONZE
     self.points = 0
Beispiel #7
0
 def __init__(self):
     Badge.__init__(self)
     self.badge_context_type = BadgeContextType.FEEDBACK
Beispiel #8
0
 def __init__(self):
     Badge.__init__(self)
     self.badge_context_type = BadgeContextType.PLAYLIST
Beispiel #9
0
 def __init__(self):
     Badge.__init__(self)
     self.description = "Express Yourself"
     self.badge_category = BadgeCategory.BRONZE
     self.points = 0
 def __init__(self):
     Badge.__init__(self)
     self.badge_context_type = BadgeContextType.EXERCISE
 def __init__(self):
     Badge.__init__(self)
     self.description = "Flag Duty"
     self.badge_category = BadgeCategory.BRONZE
     self.points = 0
 def __init__(self):
     Badge.__init__(self)
     self.description = "Thumbs Down"
     self.badge_category = BadgeCategory.BRONZE
     self.points = 0
Beispiel #13
0
 def icon_src(self):
     if self.custom_icon_src:
         return self.custom_icon_src
     return Badge.icon_src(self)
Beispiel #14
0
from styles import tier_colour
from badges import Badge

badge_obj = Badge()


class KaggleStyles:
    def __init__(self, extend=False):
        if extend == True:
            self.scale = "scale(1.2)"
            self.scaler = 1.2
            badge_obj.scale = 1.35
            self.bottom = [120, 120]
            self.medalText = "Medals :"
            self.isExtend = True

        else:
            self.scale = "scale(1)"
            self.scaler = 1
            badge_obj.scale = 1
            self.bottom = [0, 0]
            self.medalText = ""
            self.isExtend = False

    def present(self, data):

        style = """<style>
                    @import url(https://fonts.googleapis.com/css2?family=Inter);
                    @keyframes currstreak {
                        0% { font-size: 3px; opacity: 0.2; }
                        80% { font-size: 34px; opacity: 1; }
Beispiel #15
0
 def __init__(self):
     Badge.__init__(self)
     self.description = ""+u"חיזוק שלילי"
     self.badge_category = BadgeCategory.BRONZE
     self.points = 0