PageRenderTime 79ms CodeModel.GetById 2ms app.highlight 71ms RepoModel.GetById 1ms app.codeStats 0ms

/tasker/views.py

https://bitbucket.org/nkitsan/lab02
Python | 604 lines | 568 code | 36 blank | 0 comment | 70 complexity | ebb792ef033dd69e70f121c086eb1a96 MD5 | raw file
  1from django.shortcuts import render, redirect
  2from django.http import JsonResponse
  3from django.views.decorators.csrf import csrf_exempt
  4from tasker.models import User
  5from tasker.libs.apis import (habit,
  6                              event,
  7                              public_task,
  8                              private_task,
  9                              list)
 10from tasker.libs.managers import (user_manager,
 11                                  weekly_task_manager,
 12                                  public_task_manager,
 13                                  habit_tracker_manager)
 14from tasker.libs.helpers import (task_helper,
 15                                 schedule_helper,
 16                                 remembers_helper)
 17
 18
 19def home(request):
 20    if request.session.get('username') is not None:
 21        return redirect('/profiles/{}'.format(request.session.get('username')))
 22    return redirect(request, '/login')
 23
 24
 25def login(request):
 26    if request.session.get('username') is not None:
 27        return redirect('/profiles/{}'.format(request.session.get('username')))
 28    elif request.method == "GET":
 29        username = request.GET.get('username')
 30        password = request.GET.get('password')
 31        if username is not None and request is not None and user_manager.login_user(username, password):
 32            request.session['username'] = username
 33            return redirect('/profiles/{}'.format(username))
 34        else:
 35            return render(request, 'tasker/login.html')
 36    else:
 37        return render(request, 'tasker/login.html')
 38
 39
 40def signup(request):
 41    if request.session.get('username') is not None:
 42        return redirect('/profiles/{}'.format(request.session.get('username')))
 43    elif request.method == "POST":
 44        username = request.POST.get('username')
 45        email = request.POST.get('email')
 46        password = request.POST.get('password')
 47        if user_manager.signup_user(username, email, password):
 48            request.session['username'] = username
 49            return redirect('/profiles/{}'.format(username))
 50    else:
 51        return render(request, 'tasker/signup.html')
 52
 53
 54@csrf_exempt
 55def logout(request):
 56    try:
 57        del request.session['username']
 58    except KeyError:
 59        pass
 60    return redirect('/signup')
 61
 62
 63@csrf_exempt
 64def user_board(request, username):
 65    user = User.objects.get(username=username)
 66    schedule_helper.check_updates(username)
 67    return render(request, 'tasker/index.html', {'api_key': user.api_key,
 68                                                 'tasks': user.week_list.all(),
 69                                                 'lists': user.lists.all(),
 70                                                 'public_tasks': task_helper.tasks_to_dict(username),
 71                                                 'username': username})
 72
 73
 74@csrf_exempt
 75def habit_api(request, api, habit_id):
 76    if not User.objects.filter(api_key=api).exists():
 77        return JsonResponse({'error': 'wrong api key'})
 78    username = user_manager.get_username(api)
 79    schedule_helper.check_updates(username)
 80    user_habit = habit.Habit(api)
 81    if request.method == 'GET':
 82        return JsonResponse(user_habit.get_habit(habit_id))
 83    if request.method == 'PUT':
 84        habit_name = request.PUT.get('habit_name')
 85        habit_status = request.PUT.get('habit_status')
 86        habit_timeline = request.PUT.get('habit_timeline')
 87        return JsonResponse(user_habit.put_habit(habit_id, habit_name, habit_status, habit_timeline))
 88
 89
 90@csrf_exempt
 91def event_api(request, api, event_id):
 92    if not User.objects.filter(api_key=api).exists():
 93        return JsonResponse({'error': 'wrong api key'})
 94    user_event = event.Event(api)
 95    if request.method == 'GET':
 96        return JsonResponse(user_event.get_event(event_id))
 97    if request.method == 'POST':
 98        comment = request.POST.get('comment')
 99        remember = request.POST.get('remember')
100        return JsonResponse(user_event.post_event_params(event_id, comment, remember))
101    if request.method == 'PUT':
102        event_date = request.PUT.get('event_date')
103        event_name = request.PUT.get('event_name')
104        return JsonResponse(user_event.put_event(event_id, event_name, event_date))
105    if request.method == 'DELETE':
106        comment_id = request.DELETE.get('comment_id')
107        remember_id = request.DELETE.get('remember_id')
108        return JsonResponse(user_event.delete_event_params(event_id, comment_id, remember_id))
109
110
111@csrf_exempt
112def private_task_api(request, api, task_id):
113    if not User.objects.filter(api_key=api).exists():
114        return JsonResponse({'error': 'wrong api key'})
115    username = user_manager.get_username(api)
116    schedule_helper.check_updates(username)
117    user_task = private_task.PrivateTask(api)
118    if request.method == 'GET':
119        return JsonResponse(user_task.get_task(task_id))
120    if request.method == 'POST':
121        repeat = request.POST.get('repeat')
122        remember = request.POST.get('remember')
123        subtask = request.POST.get('subtask')
124        comment = request.POST.get('comment')
125        return JsonResponse(user_task.post_task_params(task_id, repeat, remember, subtask, comment))
126    if request.method == 'PUT':
127        task_name = request.PUT.get('task_name')
128        task_status = request.PUT.get('task_status')
129        task_deadline = request.PUT.get('task_deadline')
130        subtask_id = request.PUT.get('subtask_id')
131        subtask_status = request.PUT.get('subtask_status')
132        return JsonResponse(user_task.put_task(task_id, task_name, task_status, task_deadline, subtask_id,
133                                               subtask_status))
134    if request.method == 'DELETE':
135        repeat_id = request.DELETE.get('repeat_id')
136        remember_id = request.DELETE.get('remember_id')
137        subtask_id = request.DELETE.get('subtask_id')
138        comment_id = request.DELETE.get('comment_id')
139        return JsonResponse(user_task.delete_task_params(task_id, comment_id, subtask_id, repeat_id,
140                                                         remember_id))
141
142
143@csrf_exempt
144def public_task_api(request, api, list_id, task_id):
145    if not User.objects.filter(api_key=api).exists():
146        return JsonResponse({'error': 'wrong api key'})
147    user_task = public_task.PublicTask(api)
148    if request.method == 'GET':
149        return JsonResponse(user_task.get_public_task(list_id, task_id))
150    if request.method == 'POST':
151        subtask = request.POST.get('subtask')
152        comment = request.POST.get('comment')
153        executor = request.POST.get('executor')
154        return JsonResponse(user_task.post_public_task_params(list_id, task_id, comment, subtask, executor))
155    if request.method == 'PUT':
156        task_name = request.PUT.get('task_name')
157        status = request.PUT.get('task_status')
158        deadline = request.PUT.get('task_deadline')
159        subtask_id = request.PUT.get('subtask_id')
160        subtask_status = request.PUT.get('subtask_status')
161        return JsonResponse(user_task.put_public_task(list_id, task_id, task_name, status, deadline, subtask_id,
162                                                      subtask_status))
163    if request.method == 'DELETE':
164        subtask_id = request.DELETE.get('subtask_id')
165        comment_id = request.DELETE.get('comment_id')
166        executor = request.DELETE.get('executor')
167        return JsonResponse(user_task.delete_public_task_params(list_id, task_id, comment_id, subtask_id, executor))
168
169
170@csrf_exempt
171def list_api(request, api, list_id):
172    if not User.objects.filter(api_key=api).exists():
173        return JsonResponse({'error': 'wrong api key'})
174    user_list = list.List(api)
175    if request.method == 'POST':
176        new_user = request.POST.get('new_user')
177        print(new_user)
178        return JsonResponse(user_list.post_list_params(list_id, new_user))
179    if request.method == 'PUT':
180        list_name = request.PUT.get('list_name')
181        return JsonResponse(user_list.put_list(list_id, list_name))
182    if request.method == 'DELETE':
183        new_user = request.DELETE.get('new_user')
184        return JsonResponse(user_list.delete_list_params(list_id, new_user))
185
186
187@csrf_exempt
188def habits_api(request, api):
189    if not User.objects.filter(api_key=api).exists():
190        return JsonResponse({'error': 'wrong api key'})
191    username = user_manager.get_username(api)
192    schedule_helper.check_updates(username)
193    user_habit = habit.Habit(api)
194    if request.method == 'POST':
195        habit_name = request.POST.get('habit_name')
196        return JsonResponse(user_habit.post_habit(habit_name))
197    if request.method == 'GET':
198        return JsonResponse(user_habit.get_habits())
199    if request.method == 'DELETE':
200        habit_id = request.DELETE.get('habit_id')
201        return JsonResponse(user_habit.delete_habit(habit_id))
202
203
204@csrf_exempt
205def events_api(request, api):
206    if not User.objects.filter(api_key=api).exists():
207        return JsonResponse({'error': 'wrong api key'})
208    user_event = event.Event(api)
209    if request.method == 'POST':
210        event_name = request.POST.get('event_name')
211        event_date = request.POST.get('event_date')
212        return JsonResponse(user_event.post_event(event_name, event_date))
213    if request.method == 'GET':
214        return JsonResponse(user_event.get_events())
215    if request.method == 'DELETE':
216        event_id = request.DELETE.get('event_id')
217        return JsonResponse(user_event.delete_event(event_id))
218
219
220@csrf_exempt
221def private_tasks_api(request, api):
222    if not User.objects.filter(api_key=api).exists():
223        return JsonResponse({'error': 'wrong api key'})
224    username = user_manager.get_username(api)
225    schedule_helper.check_updates(username)
226    user_task = private_task.PrivateTask(api)
227    if request.method == 'POST':
228        task_name = request.POST.get('task_name')
229        return JsonResponse(user_task.post_task(task_name))
230    if request.method == 'GET':
231        return JsonResponse(user_task.get_tasks())
232    if request.method == 'DELETE':
233        task_id = request.DELETE.get('task_id')
234        return JsonResponse(user_task.delete_task(task_id))
235
236
237@csrf_exempt
238def public_tasks_api(request, api, list_id):
239    if not User.objects.filter(api_key=api).exists():
240        return JsonResponse({'error': 'wrong api key'})
241    user_task = public_task.PublicTask(api)
242    if request.method == 'POST':
243        task_name = request.POST.get('task_name')
244        return JsonResponse(user_task.post_public_tasks(list_id, task_name))
245    if request.method == 'GET':
246        return JsonResponse(user_task.get_public_tasks(list_id))
247    if request.method == 'DELETE':
248        task_id = request.DELETE.get('task_id')
249        return JsonResponse(user_task.delete_public_task(list_id, task_id))
250
251
252@csrf_exempt
253def lists_api(request, api):
254    if not User.objects.filter(api_key=api).exists():
255        return JsonResponse({'error': 'wrong api key'})
256    user_list = list.List(api)
257    if request.method == 'POST':
258        list_name = request.POST.get('list_name')
259        return JsonResponse(user_list.post_lists(list_name))
260    if request.method == 'GET':
261        return JsonResponse(user_list.get_lists())
262    if request.method == 'DELETE':
263        list_id = request.DELETE.get('list_id')
264        return JsonResponse(user_list.delete_list(list_id))
265
266
267def remembers_api(request, api):
268    if not User.objects.filter(api_key=api).exists():
269        return JsonResponse({'error': 'wrong api key'})
270    username = user_manager.get_username(api)
271    schedule_helper.check_updates(username)
272    user_event = event.Event(api)
273    user_task = private_task.PrivateTask(api)
274    if request.method == 'GET':
275        remembers_events = user_event.check_remembers()
276        remembers_tasks = user_task.check_remembers()
277        return JsonResponse({'events': remembers_events, 'tasks': remembers_tasks})
278
279
280@csrf_exempt
281def task_info(request, username, task_id):
282    task = weekly_task_manager.find_user_task(username, task_id)
283    return render(request, 'tasker/task.html', {'name': task.task.name,
284                                                'deadline': ' '.join(str(task.task.deadline)[0:-9].split('T')),
285                                                'subtasks': task.task.subtasks.all(),
286                                                'status': task.task.status,
287                                                'task_id': task_id,
288                                                'comments': task.task.comments.all(),
289                                                'remembers': task.remember.all(),
290                                                'repeats': task_helper.task_repeats(username, task_id),
291                                                'username': username})
292
293
294@csrf_exempt
295def create_task(request, username):
296    task_name = request.POST.get('title')
297    if request.method == 'POST' and request.session.get('username') == username and task_name != '':
298        weekly_task_manager.add_weeklytask(username, task_name)
299    return redirect('/profiles/{}'.format(username))
300
301
302@csrf_exempt
303def change_task(request, username, task_id):
304    if request.method == 'GET' and request.session.get('username') == username:
305        task = weekly_task_manager.find_user_task(username, task_id)
306        return render(request, 'tasker/task_change.html', {'username': username,
307                                                           'task_id': task_id,
308                                                           'task_name': task.task.name})
309    if request.method == 'POST' and request.session.get('username') == username:
310        name = request.POST.get('title')
311        date = request.POST.get('date')
312        time = request.POST.get('time')
313        status = request.POST.get('status')
314        if name != '':
315            weekly_task_manager.change_weeklytask_name(username, task_id, name)
316        if date != '':
317            if time == '':
318                time = "00:00"
319            deadline = date + ' ' + time
320            weekly_task_manager.change_weeklytask_deadline(username, task_id, deadline)
321        if status != '':
322            weekly_task_manager.change_weeklytask_status(username, task_id, status)
323    return redirect('/profiles/{}/tasks/{}'.format(username, task_id))
324
325
326@csrf_exempt
327def delete_task(request, username, task_id):
328    if request.method == 'POST' and request.session.get('username') == username:
329        weekly_task_manager.delete_weeklytask(username, task_id)
330    return redirect('/profiles/{}'.format(username))
331
332
333@csrf_exempt
334def add_subtask(request, username, task_id):
335    subtask_name = request.POST.get('title')
336    if request.method == 'POST' and request.session.get('username') == username and subtask_name != '':
337        weekly_task_manager.add_weeklytask_subtask(username, task_id, subtask_name)
338    return redirect('/profiles/{}/tasks/{}'.format(username, task_id))
339
340
341@csrf_exempt
342def change_subtask(request, username, task_id, subtask_id):
343    subtask_status = request.POST.get('subtask_status')
344    if request.method == 'POST' and request.session.get('username') == username:
345        if subtask_status is None:
346            weekly_task_manager.change_weeklytask_subtask_status(username, task_id, subtask_id, 'NS')
347        else:
348            weekly_task_manager.change_weeklytask_subtask_status(username, task_id, subtask_id, 'F')
349    return redirect('/profiles/{}/tasks/{}'.format(username, task_id))
350
351
352@csrf_exempt
353def delete_subtask(request, username, task_id, subtask_id):
354    if request.method == 'POST' and request.session.get('username') == username:
355        weekly_task_manager.delete_weeklytask_subtask(username, task_id, subtask_id)
356    return redirect('/profiles/{}/tasks/{}'.format(username, task_id))
357
358
359@csrf_exempt
360def add_comment(request, username, task_id):
361    comment = request.POST.get('text')
362    if request.method == 'POST' and request.session.get('username') == username and comment != '':
363        weekly_task_manager.add_weeklytask_comment(username, task_id, comment)
364    return redirect('/profiles/{}/tasks/{}'.format(username, task_id))
365
366
367@csrf_exempt
368def delete_comment(request, username, task_id, comment_id):
369    if request.method == 'POST' and request.session.get('username') == username:
370        weekly_task_manager.delete_weeklytask_comment(username, task_id, comment_id)
371    return redirect('/profiles/{}/tasks/{}'.format(username, task_id))
372
373
374@csrf_exempt
375def add_remember(request, username, task_id):
376    if request.method == 'POST' and request.session.get('username') == username:
377        date = request.POST.get('date')
378        time = request.POST.get('time')
379        print(time)
380        print(date)
381        if date != '':
382            if time == '':
383                time = '00:00'
384            remember = date + ' ' + time
385            weekly_task_manager.add_weeklytask_remember(username, task_id, remember)
386    return redirect('/profiles/{}/tasks/{}'.format(username, task_id))
387
388
389@csrf_exempt
390def delete_remember(request, username, task_id, remember_id):
391    if request.method == 'POST' and request.session.get('username') == username:
392        weekly_task_manager.delete_weeklytask_remember(username, task_id, remember_id)
393    return redirect('/profiles/{}/tasks/{}'.format(username, task_id))
394
395
396@csrf_exempt
397def add_repeat(request, username, task_id):
398    if request.method == 'POST' and request.session.get('username') == username:
399        repeat = request.POST.get('repeat')
400        if repeat != '':
401            weekly_task_manager.add_weeklytask_repeat(username, task_id, repeat)
402    return redirect('/profiles/{}/tasks/{}'.format(username, task_id))
403
404
405@csrf_exempt
406def delete_repeat(request, username, task_id, repeat_id):
407    if request.method == 'POST' and request.session.get('username') == username:
408        weekly_task_manager.delete_weeklytask_repeat(username, task_id, repeat_id)
409    return redirect('/profiles/{}/tasks/{}'.format(username, task_id))
410
411
412@csrf_exempt
413def create_list(request, username):
414    list_name = request.POST.get('title')
415    if request.method == 'POST' and request.session.get('username') == username and list_name != '':
416        public_task_manager.create_public_list(username, list_name)
417    return redirect('/profiles/{}'.format(username))
418
419
420@csrf_exempt
421def change_list(request, username, list_id):
422    if request.method == 'GET' and request.session.get('username') == username:
423        public_list = public_task_manager.get_user_list(username, list_id)
424        return render(request, 'tasker/list_change.html', {'public_list': public_list, 'username': username})
425    if request.method == 'POST' and request.session.get('username') == username:
426        title = request.POST.get('title')
427        new_user = request.POST.get('new_user')
428        if title != '':
429            public_task_manager.change_public_list_name(username, list_id, title)
430        if new_user != '':
431            public_task_manager.add_public_list_user(username, new_user, list_id)
432    return redirect('/profiles/{}'.format(username))
433
434
435@csrf_exempt
436def delete_list(request, username, list_id):
437    if request.method == 'POST' and request.session.get('username') == username:
438        public_task_manager.delete_public_list(username, list_id)
439    return redirect('/profiles/{}'.format(username))
440
441
442@csrf_exempt
443def create_public_task(request, username, list_id):
444    task_name = request.POST.get('title')
445    if request.method == 'POST' and request.session.get('username') == username and task_name != '':
446        public_task_manager.create_public_task(username, list_id, task_name)
447    return redirect('/profiles/{}'.format(username))
448
449
450@csrf_exempt
451def public_task_info(request, username, list_id, task_id):
452    task = public_task_manager.get_list_task(username, list_id, task_id)
453    return render(request, 'tasker/public_task.html', {'name': task.task.name,
454                                                       'deadline': ' '.join(str(task.task.deadline)[0:-9].split('T')),
455                                                       'subtasks': task.task.subtasks.all(),
456                                                       'comments': task.task.comments.all(),
457                                                       'status': task.task.status,
458                                                       'task_id': task_id,
459                                                       'list_id': list_id,
460                                                       'username': username,
461                                                       'executors': task.executors.all()})
462
463
464@csrf_exempt
465def change_public_task(request, username, list_id, task_id):
466    if request.method == 'GET' and request.session.get('username') == username:
467        task = public_task_manager.get_list_task(username, list_id, task_id)
468        public_list = public_task_manager.get_user_list(username, list_id)
469        return render(request, 'tasker/public_task_change.html', {'username': username,
470                                                                  'list_id': list_id,
471                                                                  'task_id': task_id,
472                                                                  'public_list': public_list,
473                                                                  'task_name': task.task.name})
474    if request.method == 'POST' and request.session.get('username') == username:
475        name = request.POST.get('title')
476        date = request.POST.get('date')
477        time = request.POST.get('time')
478        status = request.POST.get('status')
479        user = request.POST.get('user')
480        if name != '':
481            public_task_manager.change_public_task_name(username, list_id, task_id, name)
482        if date != '':
483            if time == '':
484                time = "00:00"
485            deadline = date + ' ' + time
486            public_task_manager.change_public_task_deadline(username, list_id, task_id, deadline)
487        if status != '':
488            public_task_manager.change_public_task_status(username, list_id, task_id, status)
489        if user != '':
490            public_task_manager.add_task_executor(username, user, list_id, task_id)
491    return redirect('/profiles/{}/lists/{}/tasks/{}'.format(username, list_id, task_id))
492
493
494@csrf_exempt
495def delete_public_task(request, username, list_id, task_id):
496    if request.method == 'POST' and request.session.get('username') == username:
497        public_task_manager.delete_public_task(username, list_id, task_id)
498    return redirect('/profiles/{}'.format(username))
499
500
501@csrf_exempt
502def add_public_subtask(request, username, list_id, task_id):
503    subtask_name = request.POST.get('title')
504    if request.method == 'POST' and request.session.get('username') == username and subtask_name != '':
505        public_task_manager.add_public_task_subtask(username, list_id, task_id, subtask_name)
506    return redirect('/profiles/{}/lists/{}/tasks/{}'.format(username, list_id, task_id))
507
508
509@csrf_exempt
510def change_public_subtask(request, username, list_id, task_id, subtask_id):
511    subtask_status = request.POST.get('subtask_status')
512    if request.method == 'POST' and request.session.get('username') == username:
513        if subtask_status is None:
514            public_task_manager.change_public_task_subtask_status(username, list_id, task_id, subtask_id, 'NS')
515        else:
516            public_task_manager.change_public_task_subtask_status(username, list_id, task_id, subtask_id, 'F')
517    return redirect('/profiles/{}/lists/{}/tasks/{}'.format(username, list_id, task_id))
518
519
520@csrf_exempt
521def delete_public_subtask(request, username, list_id, task_id, subtask_id):
522    if request.method == 'POST' and request.session.get('username') == username:
523        public_task_manager.delete_public_task_subtask(username, list_id, task_id, subtask_id)
524    return redirect('/profiles/{}/lists/{}/tasks/{}'.format(username, list_id, task_id))
525
526
527@csrf_exempt
528def add_public_comment(request, username, list_id, task_id):
529    comment = request.POST.get('text')
530    if request.method == 'POST' and request.session.get('username') == username and comment != '':
531        public_task_manager.add_public_task_comment(username, list_id, task_id, comment)
532    return redirect('/profiles/{}/lists/{}/tasks/{}'.format(username, list_id, task_id))
533
534
535@csrf_exempt
536def delete_public_comment(request, username, list_id, task_id, comment_id):
537    if request.method == 'POST' and request.session.get('username') == username:
538        public_task_manager.delete_public_task_comment(username, list_id, task_id, comment_id)
539    return redirect('/profiles/{}/lists/{}/tasks/{}'.format(username, list_id, task_id))
540
541
542@csrf_exempt
543def delete_task_executor(request, username, list_id, task_id, new_user):
544    if request.method == 'POST' and request.session.get('username') == username:
545        public_task_manager.delete_task_executor(username, new_user, list_id, task_id)
546    return redirect('/profiles/{}/lists/{}/tasks/{}'.format(username, list_id, task_id))
547
548
549@csrf_exempt
550def habits_info(request, username):
551    schedule_helper.check_updates(username)
552    habits = habit_tracker_manager.get_user_habits(username)
553    return render(request, 'tasker/habit_tracker.html', {'habits': habits,
554                                                         'username': username})
555
556
557@csrf_exempt
558def add_habit(request, username):
559    habit_name = request.POST.get('title')
560    if request.method == 'POST' and request.session.get('username') == username and habit_name != '':
561        habit_tracker_manager.create_habit(username, habit_name)
562    return redirect('/profiles/{}/habits'.format(username))
563
564
565@csrf_exempt
566def change_habit(request, username, habit_id):
567    habit_name = request.POST.get('title')
568    habit_timeline = request.POST.get('timeline')
569    if request.method == 'GET' and request.session.get('username') == username:
570        habit = habit_tracker_manager.get_user_habit(username, habit_id)
571        return render(request, 'tasker/habit_change.html', {'habit': habit,
572                                                            'username': username})
573    if request.method == 'POST' and request.session.get('username') == username:
574        habit = habit_tracker_manager.get_user_habit(username, habit_id)
575        if habit_name != '':
576            habit_tracker_manager.change_habit_name(username, habit_id, habit_name)
577        if habit_timeline != '' and habit_timeline.isdigit() and int(habit_timeline) >= habit.count:
578            habit_tracker_manager.change_habit_timeline(username, habit_id, habit_timeline)
579    return redirect('/profiles/{}/habits'.format(username))
580
581
582@csrf_exempt
583def delete_habit(request, username, habit_id):
584    if request.method == 'POST' and request.session.get('username') == username:
585        habit_tracker_manager.delete_habit(username, habit_id)
586    return redirect('/profiles/{}/habits'.format(username))
587
588
589@csrf_exempt
590def change_habit_status(request, username, habit_id):
591    habit_status = request.POST.get('habit_status')
592    if request.method == 'POST' and request.session.get('username') == username:
593        if habit_status is None:
594            habit_tracker_manager.change_habit_status(username, habit_id, 'NS')
595        else:
596            habit_tracker_manager.change_habit_status(username, habit_id, 'F')
597    return redirect('/profiles/{}/habits'.format(username))
598
599
600@csrf_exempt
601def remember_info(request, username):
602    remembers = remembers_helper.check_remembers(username)
603    return render(request, 'tasker/remembers.html', {'remembers': remembers,
604                                                     'username': username})