Commit 25c6d69732163db260f6dab151195e85e12bbaa5
1 parent
dc942208b9
Exists in
master
Changed registration_token to registration_id for increased consisitency
Showing 5 changed files with 26 additions and 7 deletions Side-by-side Diff
flashcards/management/commands/notifyusers.py
View file @
25c6d69
... | ... | @@ -11,7 +11,7 @@ |
11 | 11 | notify_list = UserFlashcard.objects.filter( |
12 | 12 | next_review__lte=Now() |
13 | 13 | ).exclude( |
14 | - user__registration_token=None, | |
14 | + user__registration_id=None, | |
15 | 15 | user__last_notified__range=(now()-timedelta(days=1), now()) |
16 | 16 | ).values_list('user').distinct().all() |
17 | 17 |
flashcards/migrations/0017_auto_20150601_2001.py
View file @
25c6d69
1 | +# -*- coding: utf-8 -*- | |
2 | +from __future__ import unicode_literals | |
3 | + | |
4 | +from django.db import models, migrations | |
5 | + | |
6 | + | |
7 | +class Migration(migrations.Migration): | |
8 | + | |
9 | + dependencies = [ | |
10 | + ('flashcards', '0016_user_last_notified'), | |
11 | + ] | |
12 | + | |
13 | + operations = [ | |
14 | + migrations.RenameField( | |
15 | + model_name='user', | |
16 | + old_name='registration_token', | |
17 | + new_name='registration_id', | |
18 | + ), | |
19 | + ] |
flashcards/models.py
View file @
25c6d69
... | ... | @@ -71,7 +71,7 @@ |
71 | 71 | REQUIRED_FIELDS = [] |
72 | 72 | sections = ManyToManyField('Section', help_text="The sections which the user is enrolled in") |
73 | 73 | confirmed_email = BooleanField(default=False) |
74 | - registration_token = CharField(null=True, default=None, max_length=4096) | |
74 | + registration_id = CharField(null=True, default=None, max_length=4096) | |
75 | 75 | last_notified = DateTimeField(null=True, default=None) |
76 | 76 | |
77 | 77 | @property |
78 | 78 | |
... | ... | @@ -92,14 +92,14 @@ |
92 | 92 | def notify(self): |
93 | 93 | gcm = GCM(GCM_API_KEY) |
94 | 94 | gcm.plaintext_request( |
95 | - registration_id=self.registration_token, | |
95 | + registration_id=self.registration_id, | |
96 | 96 | data="You have flashcards to study!" |
97 | 97 | ) |
98 | 98 | self.last_notified = now() |
99 | 99 | self.save() |
100 | 100 | |
101 | - def set_registration_token(self, token): | |
102 | - self.registration_token = token | |
101 | + def set_registration_id(self, token): | |
102 | + self.registration_id = token | |
103 | 103 | self.save() |
104 | 104 | |
105 | 105 | def is_in_section(self, section): |
flashcards/serializers.py
View file @
25c6d69
flashcards/views.py
View file @
25c6d69
... | ... | @@ -243,7 +243,7 @@ |
243 | 243 | """ |
244 | 244 | serializer = SubscribeViewSerializer(data=request.data) |
245 | 245 | serializer.is_valid(raise_exception=True) |
246 | - request.user.set_registration_token(serializer.validated_data['registration_token']) | |
246 | + request.user.set_registration_id(serializer.validated_data['registration_id']) | |
247 | 247 | return Response(status=HTTP_204_NO_CONTENT) |
248 | 248 | |
249 | 249 |