diff --git a/website/migrations/0028_auto_20170705_2359.py b/website/migrations/0028_auto_20170705_2359.py new file mode 100644 index 000000000..0128b40e7 --- /dev/null +++ b/website/migrations/0028_auto_20170705_2359.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.2 on 2017-07-05 23:59 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('website', '0027_issue_label'), + ] + + operations = [ + migrations.AlterField( + model_name='issue', + name='label', + field=models.PositiveSmallIntegerField(choices=[(0, b'General'), (1, b'Number Error'), (2, b'Functional'), (3, b'Performance'), (4, b'Security'), (5, b'Typo'), (6, b'Design')], default=0), + ), + ] diff --git a/website/migrations/0029_userprofile_title.py b/website/migrations/0029_userprofile_title.py new file mode 100644 index 000000000..81f9a0a35 --- /dev/null +++ b/website/migrations/0029_userprofile_title.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.2 on 2017-07-06 06:31 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('website', '0028_auto_20170705_2359'), + ] + + operations = [ + migrations.AddField( + model_name='userprofile', + name='title', + field=models.IntegerField(choices=[(0, b'Unrated'), (1, b'Bronze'), (2, b'Silver'), (3, b'Gold'), (4, b'Platinum')], default=0), + ), + ] diff --git a/website/models.py b/website/models.py index 7247a9cef..2b26f36b9 100644 --- a/website/models.py +++ b/website/models.py @@ -293,9 +293,19 @@ def user_images_path(instance, filename): class UserProfile(models.Model): + title = ( + (0, 'Unrated'), + (1, 'Bronze'), + (2, 'Silver'), + (3, 'Gold'), + (4, 'Platinum'), + ) + user = models.OneToOneField(User, related_name="userprofile") user_avatar = models.ImageField(upload_to=user_images_path, blank=True, null=True) + title = models.IntegerField(choices=title,default=0) + def avatar(self, size=36): if self.user_avatar: diff --git a/website/templates/base.html b/website/templates/base.html index c43142f43..4ed433994 100644 --- a/website/templates/base.html +++ b/website/templates/base.html @@ -128,7 +128,7 @@ {% endif %} - @@ -144,7 +144,7 @@ {% else %} -   @@ -157,7 +157,7 @@ {% endif %} - + diff --git a/website/templates/index.html b/website/templates/index.html index 6a7a871ac..e2475c1f4 100644 --- a/website/templates/index.html +++ b/website/templates/index.html @@ -92,7 +92,7 @@

Design

Featured Websites

-
+
{% for domain in domains %}
@@ -192,7 +192,7 @@

Featured Websites

-
+

Latest activity

diff --git a/website/templates/leaderboard.html b/website/templates/leaderboard.html index d330b9bf4..57d449c0e 100644 --- a/website/templates/leaderboard.html +++ b/website/templates/leaderboard.html @@ -13,6 +13,19 @@ text-decoration: none; margin-left: 10px; } +.silver { + background-color: lightblue; + color: #333; +} +.gold { + background-color: #D4AF37; + color: #333; +} +.bronze { + background-color: #C9AE5D; + color: #333; +} + {% endblock %} {% block content %} @@ -33,9 +46,11 @@

Global Leaderboard

{% endif %} {{leader.username}} {{leader.total_score}} Points + {{ leader.userprofile.get_title_display }}
{% endfor %}
-{% endblock %} \ No newline at end of file +{% endblock %} + \ No newline at end of file diff --git a/website/templates/profile.html b/website/templates/profile.html index 176e2bd74..5d2495170 100644 --- a/website/templates/profile.html +++ b/website/templates/profile.html @@ -17,6 +17,24 @@ .list-group .label-default { margin-top:3px; } +.block-icon { + font-size: 90px; + line-height: 70px; + margin-top: -40px; +} +.silver { + background-color: lightblue; + color: #333; +} +.gold { + background-color: #D4AF37; + color: #333; +} +.bronze { + background-color: #C9AE5D; + color: #333; +} + {% endblock %} {% block content %} @@ -25,11 +43,23 @@

{{ user.username }}

{% if user.userprofile.avatar %} + {% else %} {% endif %} +

{{ user.userprofile.get_title_display }} Total bugs:{{ activities | length }}

+
+ + {{ bug_type_1 | length }} + {{ bug_type_2 | length }} + {{ bug_type_3 | length }} + {{ bug_type_4 | length}} + {{ bug_type_5 | length}} + {{ bug_type_6 | length}} +
+ {% if request.user == user %}
{% csrf_token %} diff --git a/website/views.py b/website/views.py index b0b96b31a..8b3168c5f 100644 --- a/website/views.py +++ b/website/views.py @@ -16,7 +16,7 @@ from django.contrib.auth.models import User from actstream import registry from django.http import JsonResponse -from website.models import Issue, Points, Hunt, Domain, InviteFriend +from website.models import Issue, Points, Hunt, Domain, InviteFriend, UserProfile from django.core.files import File from django.core.urlresolvers import reverse, reverse_lazy from django.db.models import Sum, Count @@ -188,6 +188,19 @@ def form_valid(self, form): obj.screenshot.save(self.request.POST.get('screenshot-hash') +'.png', django_file, save=True) obj.user_agent = self.request.META.get('HTTP_USER_AGENT') obj.save() + + total_issues = Issue.objects.filter(user=self.request.user).count() + user_prof = UserProfile.objects.get(user=self.request.user) + if total_issues <=10: + user_prof.title = 1 + elif total_issues <=50: + user_prof.title = 2 + elif total_issues <= 200: + user_prof.title = 3 + else: + user_prof.title = 4 + + user_prof.save() if domain.github and os.environ.get("GITHUB_PASSWORD"): from giturlparse import parse @@ -288,6 +301,8 @@ def get_context_data(self, **kwargs): context['websites'] = Domain.objects.filter(issue__user=self.object).annotate(total=Count('issue')).order_by('-total') context['activities'] = user_stream(self.object, with_user_activity=True) context['profile_form'] = UserProfileForm() + for i in range(1,7): + context['bug_type_'+str(i)] = Issue.objects.filter(user=self.object,label=str(i)) return context @method_decorator(login_required)