-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Notice #3
base: mobile_api
Are you sure you want to change the base?
Notice #3
Conversation
AwaleRohin
commented
Jul 24, 2019
- added validation for user register, leave apply and compensation apply
- added notice model
- @shakyasaijal @Xkid0525
department/models.py
Outdated
|
||
|
||
class Notice(models.Model): | ||
topic = models.CharField(max_length=100, default="Emergency Notice") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does nullable works?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BROTHER Have you done this job in laravel?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
view? say notice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then it would be /notice/notice
department/views.py
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use get rather than filter. with try catch. What if id = 5000000 is given?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -40,6 +42,13 @@ def apply_leave(**kwargs): | |||
reverse_lazy('leave_manager_leave_requests'))) | |||
} | |||
if send_email_notification(update_details=update_details): | |||
try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return what on exception
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DoesNotExist
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return what on Exception? @AwaleRohin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nothing because if there is fcm token then notification will be sent otherwise do nothing and continue with process
lms_user/common/valiadtion.py
Outdated
try: | ||
existing_user = User.objects.get(email=request.POST['email']) | ||
print(existing_user) | ||
context.update({'message': 'Could register to LMS. Email Already exists'}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Message?
@AwaleRohin
lms_user/views.py
Outdated
@@ -17,6 +17,8 @@ | |||
from django.utils.http import urlsafe_base64_decode | |||
import jwt | |||
import yaml | |||
from lms_user import models as lms_user_models | |||
from lms_user.common import valiadtion as validation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spelling?
lms_user/views.py
Outdated
return render(request, 'lms_user/register.html', context=context) | ||
except Exception as e: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DoesNotExist
mobile_api/views.py
Outdated
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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use DoesNotExist
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done