Bug 649652 - Login on mobile is now required to get the Multi-sparker badge
This commit is contained in:
Родитель
2d8a3bed98
Коммит
d034052523
|
@ -67,7 +67,7 @@ all_challenges[_id(2, 2)] = TwitterThreat()
|
|||
class Multisparker(ChallengeImpl):
|
||||
""" Sign in on both your phone and your desktop Web browser """
|
||||
def is_completed_by(self, profile):
|
||||
return profile.login_desktop
|
||||
return profile.login_desktop and profile.login_mobile
|
||||
|
||||
all_challenges[_id(2, 3)] = Multisparker()
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ class Profile(models.Model):
|
|||
|
||||
# Flags
|
||||
login_desktop = models.BooleanField(default=False)
|
||||
login_mobile = models.BooleanField(default=False)
|
||||
is_non_android = models.BooleanField(default=False)
|
||||
|
||||
# Personal stats
|
||||
|
@ -297,12 +298,10 @@ class Profile(models.Model):
|
|||
pass
|
||||
|
||||
|
||||
def trigger_desktop_login_badge(self):
|
||||
def trigger_multisparker_badge(self):
|
||||
from challenges.tasks import update_completed_challenges
|
||||
|
||||
if not self.login_desktop:
|
||||
self.login_desktop = True
|
||||
self.save()
|
||||
if self.login_desktop and self.login_mobile:
|
||||
update_completed_challenges(self.user.id)
|
||||
|
||||
|
||||
|
|
|
@ -45,6 +45,11 @@ def login(request, mobile=False):
|
|||
next_url = next or reverse('mobile.home')
|
||||
|
||||
if request.user.is_authenticated():
|
||||
profile = request.user.profile
|
||||
if not profile.login_mobile:
|
||||
profile.login_mobile = True
|
||||
profile.save()
|
||||
profile.trigger_multisparker_badge()
|
||||
return HttpResponseRedirect(next_url)
|
||||
|
||||
return jingo.render(request, 'users/mobile/login.html',
|
||||
|
@ -55,7 +60,12 @@ def login(request, mobile=False):
|
|||
return {'status': 'error',
|
||||
'errors': dict(form.errors.iteritems())}
|
||||
else:
|
||||
request.user.profile.trigger_desktop_login_badge()
|
||||
profile = request.user.profile
|
||||
if not profile.login_desktop:
|
||||
profile.login_desktop = True
|
||||
profile.save()
|
||||
profile.trigger_multisparker_badge()
|
||||
|
||||
return {'status': 'success',
|
||||
'next': next or reverse('desktop.home')}
|
||||
|
||||
|
@ -103,7 +113,12 @@ def register(request, mobile=False):
|
|||
|
||||
# Set a flag for mobile menu notifications
|
||||
profile = User.objects.get(username=form.cleaned_data['username']).profile
|
||||
profile.new_challenges = True
|
||||
profile.new_challenges = True
|
||||
# Set desktop or mobile login flag
|
||||
if mobile:
|
||||
profile.login_mobile = True
|
||||
else:
|
||||
profile.login_desktop = True
|
||||
profile.save()
|
||||
|
||||
if mobile:
|
||||
|
|
|
@ -9,11 +9,11 @@ INSERT INTO auth_user VALUES
|
|||
|
||||
|
||||
INSERT INTO users_profile VALUES
|
||||
(1,1,0,1,NULL,NULL,NULL,'Paris','FR',NULL,1,1,'bob',NULL,0,0,0),
|
||||
(2,1,0,0,NULL,NULL,NULL,NULL,NULL,NULL,0,1,'john',NULL,0,0,0),
|
||||
(3,1,0,0,NULL,NULL,NULL,NULL,NULL,NULL,0,1,'batman',NULL,0,0,0),
|
||||
(4,4,0,1,NULL,NULL,NULL,'New York','US',NULL,1,1,NULL,NULL,0,0,0),
|
||||
(5,2,0,1,NULL,NULL,NULL,NULL,NULL,NULL,1,1,NULL,NULL,0,0,0);
|
||||
(1,1,0,1,NULL,NULL,NULL,'Paris','FR',NULL,1,1,'bob',NULL,0,0,0,0),
|
||||
(2,1,0,0,NULL,NULL,NULL,NULL,NULL,NULL,0,1,'john',NULL,0,0,0,0),
|
||||
(3,1,0,0,NULL,NULL,NULL,NULL,NULL,NULL,0,1,'batman',NULL,0,0,0,0),
|
||||
(4,4,0,1,NULL,NULL,NULL,'New York','US',NULL,1,1,NULL,NULL,0,0,0,0),
|
||||
(5,2,0,1,NULL,NULL,NULL,NULL,NULL,NULL,1,1,NULL,NULL,0,0,0,0);
|
||||
|
||||
|
||||
INSERT INTO users_tree VALUES
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
|
||||
-- Bug 649652: Multi-sparker badge requires a new profile flag since registration is now available on desktop
|
||||
ALTER TABLE `users_profile` ADD COLUMN `login_mobile` bool NOT NULL AFTER `login_desktop`;
|
Загрузка…
Ссылка в новой задаче