Révision e147eff6
Ajouté par Serghei Mihai il y a plus de 7 ans
corbo/api_views.py | ||
---|---|---|
79 | 79 |
else: |
80 | 80 |
subcriptions.filter(identifier=identifier).delete() |
81 | 81 |
|
82 |
if uuid: |
|
83 |
if 'homepage' in transports: |
|
84 |
subcriptions.get_or_create(uuid=uuid) |
|
85 |
else: |
|
86 |
subcriptions.filter(identifier='', uuid=uuid).delete() |
|
87 |
|
|
88 | 82 |
def get(self, request): |
89 | 83 |
email = request.GET.get('email') |
90 | 84 |
uuid = request.GET.get('uuid') |
corbo/migrations/0002_auto_20150127_2221.py | ||
---|---|---|
15 | 15 |
name='Broadcast', |
16 | 16 |
fields=[ |
17 | 17 |
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), |
18 |
('channel', models.CharField(max_length=32, verbose_name='channel', choices=[(b'homepage', 'Homepage'), (b'sms', 'SMS'), (b'email', 'Email')])),
|
|
18 |
('channel', models.CharField(max_length=32, verbose_name='channel', choices=[(b'sms', 'SMS'), (b'email', 'Email')])), |
|
19 | 19 |
('time', models.DateTimeField(auto_now_add=True, verbose_name='sent time')), |
20 | 20 |
('result', models.TextField(verbose_name='result', blank=True)), |
21 | 21 |
('announce', models.ForeignKey(verbose_name='announce', to='corbo.Announce')), |
corbo/migrations/0004_auto_20160504_1744.py | ||
---|---|---|
21 | 21 |
migrations.AddField( |
22 | 22 |
model_name='subscription', |
23 | 23 |
name='identifier', |
24 |
field=models.CharField(help_text='ex.: mailto, homepage, ...', max_length=128, verbose_name='identifier', blank=True),
|
|
24 |
field=models.CharField(help_text='ex.: mailto, ...', max_length=128, verbose_name='identifier', blank=True), |
|
25 | 25 |
preserve_default=True, |
26 | 26 |
), |
27 | 27 |
migrations.AddField( |
corbo/models.py | ||
---|---|---|
24 | 24 |
|
25 | 25 |
channel_choices = ( |
26 | 26 |
('mailto', _('Email')), |
27 |
('homepage', _('Homepage')) |
|
28 | 27 |
) |
29 | 28 |
|
30 | 29 |
UNSUBSCRIBE_LINK_PLACEHOLDER = '##UNSUBSCRIBE_LINK_PLACEHOLDER##' |
... | ... | |
186 | 185 |
category = models.ForeignKey('Category', verbose_name=_('Category')) |
187 | 186 |
uuid = models.CharField(_('User identifier'), max_length=128, blank=True) |
188 | 187 |
identifier = models.CharField(_('identifier'), max_length=128, blank=True, |
189 |
help_text=_('ex.: mailto, homepage, ...'))
|
|
188 |
help_text=_('ex.: mailto, ...')) |
|
190 | 189 |
|
191 | 190 |
def get_identifier_display(self): |
192 | 191 |
try: |
tests/test_api.py | ||
---|---|---|
29 | 29 |
a = Announce.objects.create(category=category, title='By email') |
30 | 30 |
Broadcast.objects.create(announce=a) |
31 | 31 |
announces.append(a) |
32 |
a = Announce.objects.create(category=category, title='On homepage')
|
|
32 |
a = Announce.objects.create(category=category, title='Another one')
|
|
33 | 33 |
Broadcast.objects.create(announce=a) |
34 | 34 |
announces.append(a) |
35 | 35 |
return announces |
... | ... | |
44 | 44 |
assert 'text' in category |
45 | 45 |
assert category['text'] in CATEGORIES |
46 | 46 |
assert 'transports' in category |
47 |
assert category['transports'] == [{'id': 'mailto', 'text': 'Email'}, |
|
48 |
{'id': 'homepage', 'text': 'Homepage'} |
|
49 |
] |
|
47 |
assert category['transports'] == [{'id': 'mailto', 'text': 'Email'}] |
|
50 | 48 |
|
51 | 49 |
|
52 | 50 |
def test_get_subscriptions_by_email(app, categories, announces): |
Formats disponibles : Unified diff
remove "homepage" transport (#13212)