Notice#3
Conversation
AwaleRohin
commented
Jul 24, 2019
- added validation for user register, leave apply and compensation apply
- added notice model
- @shakyasaijal @Xkid0525
|
|
||
|
|
||
| class Notice(models.Model): | ||
| topic = models.CharField(max_length=100, default="Emergency Notice") |
There was a problem hiding this comment.
BROTHER Have you done this job in laravel?
There was a problem hiding this comment.
No we have not done this in laravel.
| urlpatterns = [ | ||
| path('', dept_views.create_notice, name='notice'), | ||
| path("delete/<int:id>", dept_views.delete_notice, name="notice-delete"), | ||
| path('view',dept_views.get_notice,name='notice-board'), |
There was a problem hiding this comment.
then it would be /notice/notice
| def delete_notice(request,id): | ||
| if not request.user.is_authenticated: | ||
| return HttpResponseRedirect(reverse('user-login')) | ||
| notice = Notice.objects.filter(id=id) |
There was a problem hiding this comment.
use get rather than filter. with try catch. What if id = 5000000 is given?
| reverse_lazy('leave_manager_leave_requests'))) | ||
| } | ||
| if send_email_notification(update_details=update_details): | ||
| try: |
There was a problem hiding this comment.
DoesNotExist Again same @AwaleRohin
| try: | ||
| leave_issuer_fcm = user.fcm_token | ||
| fcm(leave_issuer_fcm,request.user.get_full_name(),"approve_leave") | ||
| except Exception as e: |
There was a problem hiding this comment.
return False on Exception hainara? @AwaleRohin
| leave_issuer_fcm = user.fcm_token | ||
| fcm(leave_issuer_fcm,request.user.get_full_name(),"reject_leave") | ||
| except Exception as e: | ||
| print(e) |
There was a problem hiding this comment.
nothing because if there is fcm token then notification will be sent otherwise do nothing and continue with process
| leave_issuer = lms_user_models.LmsUser.objects.get(user=leave_details['issuer']) | ||
| leave_issuer_fcm = leave_issuer.fcm_token | ||
| fcm(leave_issuer_fcm,user,"compensation_apply") | ||
| except Exception as e: |
| leave_issuer_fcm = user.fcm_token | ||
| fcm(leave_issuer_fcm,request.user.get_full_name(),"reject_compensation") | ||
| except Exception as e: | ||
| print(e) |
There was a problem hiding this comment.
return what on Exception? @AwaleRohin
There was a problem hiding this comment.
nothing because if there is fcm token then notification will be sent otherwise do nothing and continue with process
| try: | ||
| existing_user = User.objects.get(email=request.POST['email']) | ||
| print(existing_user) | ||
| context.update({'message': 'Could register to LMS. Email Already exists'}) |
| import jwt | ||
| import yaml | ||
| from lms_user import models as lms_user_models | ||
| from lms_user.common import valiadtion as validation |
| user.delete() | ||
| context.update({'message': 'Could register to LMS. Please contact Admin or try again later'}) | ||
| return render(request, 'lms_user/register.html', context=context) | ||
| except Exception as e: |
| leave_issuer_fcm = leave_issuer.fcm_token | ||
| leave_manager.apply_CompensationLeave(request=request, leave_details=leave_detail) | ||
| fcm(leave_issuer_fcm,user,"compensation_apply") | ||
| except Exception as e: |