mirror of
https://github.com/viq/NewsBlur.git
synced 2025-08-05 16:49:45 +00:00
29 lines
No EOL
969 B
Python
29 lines
No EOL
969 B
Python
from apps.categories.models import MCategory
|
|
from utils import json_functions as json
|
|
from utils.user_functions import ajax_login_required
|
|
|
|
@json.json_view
|
|
def all_categories(request):
|
|
categories = MCategory.serialize()
|
|
|
|
return categories
|
|
|
|
@ajax_login_required
|
|
@json.json_view
|
|
def subscribe(request):
|
|
user = request.user
|
|
categories = MCategory.serialize()
|
|
category_titles = [c['title'] for c in categories['categories']]
|
|
subscribe_category_titles = request.POST.getlist('category')
|
|
|
|
invalid_category_title = False
|
|
for category_title in subscribe_category_titles:
|
|
if category_title not in category_titles:
|
|
invalid_category_title = True
|
|
|
|
if not subscribe_category_titles or invalid_category_title:
|
|
message = "Choose one or more of these categories: %s" % ', '.join(category_titles)
|
|
return dict(code=-1, message=message)
|
|
|
|
for category_title in categories:
|
|
pass |