Skip to content

Notice#3

Open
AwaleRohin wants to merge 10 commits into
mobile_apifrom
notice
Open

Notice#3
AwaleRohin wants to merge 10 commits into
mobile_apifrom
notice

Conversation

@AwaleRohin
Copy link
Copy Markdown
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
Comment thread department/models.py Outdated


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

Choose a reason for hiding this comment

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

does nullable works?

Copy link
Copy Markdown

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
Copy Markdown
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.

Comment thread department/urls.py
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'),
Copy link
Copy Markdown

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
Copy Markdown
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

Comment thread 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)
Copy link
Copy Markdown

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
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

done

Comment thread leave_manager/common/leave_manager.py Outdated
reverse_lazy('leave_manager_leave_requests')))
}
if send_email_notification(update_details=update_details):
try:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

DoesNotExist Again same @AwaleRohin

Comment thread leave_manager/common/leave_manager.py Outdated
try:
leave_issuer_fcm = user.fcm_token
fcm(leave_issuer_fcm,request.user.get_full_name(),"approve_leave")
except Exception as e:
Copy link
Copy Markdown

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

Comment thread leave_manager/common/leave_manager.py Outdated
leave_issuer_fcm = user.fcm_token
fcm(leave_issuer_fcm,request.user.get_full_name(),"reject_leave")
except Exception as e:
print(e)
Copy link
Copy Markdown

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
Copy Markdown
Collaborator Author

@AwaleRohin AwaleRohin Jul 24, 2019

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

Comment thread leave_manager/common/leave_manager.py Outdated
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:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

DoesNotExist

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done

Comment thread leave_manager/common/leave_manager.py Outdated
leave_issuer_fcm = user.fcm_token
fcm(leave_issuer_fcm,request.user.get_full_name(),"reject_compensation")
except Exception as e:
print(e)
Copy link
Copy Markdown

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
Copy Markdown
Collaborator Author

@AwaleRohin AwaleRohin Jul 24, 2019

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

Comment thread 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'})
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Message?
@AwaleRohin

Comment thread lms_user/views.py Outdated
import jwt
import yaml
from lms_user import models as lms_user_models
from lms_user.common import valiadtion as validation
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

spelling?

Comment thread lms_user/views.py Outdated
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:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

DoesNotExist

Comment thread 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:
Copy link
Copy Markdown

@shakyasaijal shakyasaijal Jul 24, 2019

Choose a reason for hiding this comment

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

use DoesNotExist

Copy link
Copy Markdown
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.

4 participants