Skip to content
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

Open
wants to merge 10 commits into
base: mobile_api
Choose a base branch
from
Open

Notice #3

wants to merge 10 commits into from

Conversation

AwaleRohin
Copy link
Collaborator

  • added validation for user register, leave apply and compensation apply
  • added notice model
  • @shakyasaijal @Xkid0525

@AwaleRohin AwaleRohin added bug Something isn't working enhancement New feature or request labels Jul 24, 2019


class Notice(models.Model):
topic = models.CharField(max_length=100, default="Emergency Notice")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does nullable works?

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?

Copy link
Collaborator Author

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'),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

view? say notice

Copy link
Collaborator Author

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

def delete_notice(request,id):
if not request.user.is_authenticated:
return HttpResponseRedirect(reverse('user-login'))
notice = Notice.objects.filter(id=id)

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?

Copy link
Collaborator Author

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:

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:

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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return what on exception

Copy link
Collaborator Author

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:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DoesNotExist

Copy link
Collaborator Author

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)

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

Copy link
Collaborator Author

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

try:
existing_user = User.objects.get(email=request.POST['email'])
print(existing_user)
context.update({'message': 'Could register to LMS. Email Already exists'})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Message?
@AwaleRohin

@@ -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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spelling?

return render(request, 'lms_user/register.html', context=context)
except Exception as e:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DoesNotExist

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:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use DoesNotExist

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants