Révision 40b65753
Ajouté par Serghei Mihai (congés, retour 15/05) il y a plus de 7 ans
corbo/api_views.py | ||
---|---|---|
33 | 33 |
newsletters = [] |
34 | 34 |
transports = [{'id': identifier, 'text': name} for identifier, name in channel_choices] |
35 | 35 |
for c in Category.objects.all(): |
36 |
newsletter = {'id': str(c.pk), 'text': c.name,
|
|
36 |
newsletter = {'id': c.slug, 'text': c.name,
|
|
37 | 37 |
'transports': transports} |
38 | 38 |
newsletters.append(newsletter) |
39 | 39 |
return Response({'data': newsletters}) |
... | ... | |
46 | 46 |
identifier = 'mailto:' + email |
47 | 47 |
for s in Subscription.objects.filter(Q(identifier=identifier) | Q(uuid=uuid)): |
48 | 48 |
cat_id = s.category.pk |
49 |
subscriptions[cat_id]['id'] = str(cat_id)
|
|
49 |
subscriptions[cat_id]['id'] = s.category.slug
|
|
50 | 50 |
subscriptions[cat_id]['text'] = s.category.name |
51 | 51 |
transport_id, transport_name = identifier.split(':') |
52 | 52 |
transport = {'id': transport_id, |
... | ... | |
59 | 59 |
return subscriptions.values() |
60 | 60 |
|
61 | 61 |
@transaction.atomic |
62 |
def update_subscriptions(self, category_id, transports, email, uuid=None):
|
|
62 |
def update_subscriptions(self, category_slug, transports, email, uuid=None):
|
|
63 | 63 |
uuid = uuid or u'' |
64 | 64 |
identifier = u'mailto:' |
65 | 65 |
if email: |
66 | 66 |
identifier += email |
67 | 67 |
try: |
68 |
cat = Category.objects.get(pk=category_id)
|
|
68 |
cat = Category.objects.get(slug=category_slug)
|
|
69 | 69 |
except Category.DoesNotExist: |
70 | 70 |
return |
71 | 71 |
|
Formats disponibles : Unified diff
api: use categories slugs instead of ids (#13791)