-
Notifications
You must be signed in to change notification settings - Fork 14
Notice #3
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
Open
AwaleRohin
wants to merge
10
commits into
mobile_api
Choose a base branch
from
notice
base: mobile_api
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Notice #3
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7f5ac45
feat:added Notice model
AwaleRohin c4f69b6
bug:added validators and added mobile notification for leave apply fr…
AwaleRohin f354b51
bug:added email notification when rejecting/approving leaves from mob…
AwaleRohin 2ef4e00
bug:added validation for register user, leave apply, compensation apply
AwaleRohin ea5f06a
bug:validation added
AwaleRohin 158074c
bug:added validation for mobile as well
AwaleRohin cd0b31e
bug:fixed dob validation
AwaleRohin 76d1845
bug:fixed username validation
AwaleRohin 680d3ff
bug:fixed compensation approved method
AwaleRohin cd105fa
bug:minor bugs fixed
AwaleRohin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,14 @@ | ||
| from django.contrib import admin | ||
| from department.models import Department | ||
| from department import models as dept_models | ||
|
|
||
|
|
||
| # Register your models here. | ||
|
|
||
| @admin.register(Department) | ||
| @admin.register(dept_models.Department) | ||
| class DepartmentAdmin(admin.ModelAdmin): | ||
| list_display = ('department',) | ||
|
|
||
|
|
||
| @admin.register(dept_models.Notice) | ||
| class DepartmentAdmin(admin.ModelAdmin): | ||
| list_display = ('topic',) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| from django import forms | ||
| from .models import Notice | ||
|
|
||
|
|
||
| class NoticeForm(forms.ModelForm): | ||
| class Meta: | ||
| model = Notice | ||
| fields = '__all__' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| {% extends 'leave_manager/layout.html' %} | ||
| {% load static %} | ||
|
|
||
| {% block content %} | ||
| <div class="container-fluid"> | ||
| <div class="row"> | ||
| <div class="col-md-8 col-md-offset-2 mx-auto"> | ||
| <div class="card"> | ||
| <div class="header"> | ||
| <h4 class="title">Send New Notice</h4> | ||
| </div> | ||
| <form method="POST" class="register-form" id="register-form" enctype ="multipart/form-data"> | ||
| {% csrf_token %} | ||
| {% load addcss %} | ||
| <div class="content"> | ||
| {% for field in form %} | ||
| {{field.errors}} | ||
| <div class="row"> | ||
| <div class="col-md-12"> | ||
| <div class="form-group"> | ||
| <label>{{field.label_tag}}</label> | ||
| {{field|addcss:"form-control"}} | ||
| </div> | ||
| </div> | ||
| </div> | ||
| {% endfor %} | ||
| <div class="row"> | ||
| <div class="col-md-12"> | ||
| <div class="form-group form-button"> | ||
| <button type="submit" name="signup" id="signup" class="btn btn-fill btn-info pull-right">Submit</button> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </form> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| {% endblock content %} | ||
|
|
||
| {% block welcome_message %} | ||
| {% if message %} | ||
| <script type="text/javascript"> | ||
| $(document).ready(function () { | ||
| $.notify({ | ||
| icon: 'pe-7s-info', | ||
| message: "{{ message }}" | ||
|
|
||
| }, { | ||
| type: type[4], | ||
| timer: 4 | ||
| }); | ||
|
|
||
| }); | ||
| </script> | ||
| {% endif %} | ||
| {% endblock welcome_message %} | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| {% extends 'leave_manager/layout.html' %} | ||
| {% load static %} | ||
|
|
||
| {% block content %} | ||
| <div class="container-fluid"> | ||
| <div class="row"> | ||
| <div class="{% if leave_issuer %} col-md-10 {% else %} col-md-12 {% endif %}"> | ||
| {% if notices %} | ||
| {% for notice in notices %} | ||
| <div class="card" style="width: 100%;padding:5px"> | ||
| <div class="card-body"> | ||
| <h4 style="text-align:center;margin-botton:3px;">{{ notice.topic }} | ||
| {% if leave_issuer %} | ||
| <form action="{% url 'notice-delete' notice.id %}" method="post"> | ||
| {% csrf_token %} | ||
| <button class="btn btn-danger btn-flat margin btn-sm" style="float:right;position:relative;top:-54px; margin-right:20px;" type="submit"> | ||
| <i class="fa fa-trash" aria-hidden="true"></i> | ||
| </button> | ||
| </form> | ||
| {% endif %} | ||
| </h4> | ||
| <hr style="width:100%"> | ||
| <p class="card-text" style="text-align:center;">{{ notice.message }}</p> | ||
| </div> | ||
| </div> | ||
| {% endfor %} | ||
| {% else %} | ||
| <tr> | ||
| <td colspan=4> | ||
| <h5>No Notice</h5> | ||
| </td> | ||
| </tr> | ||
| {% endif %} | ||
| </div> | ||
| </div> | ||
| </div> | ||
| {% endblock content %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| from django.urls import path | ||
| from department import views as dept_views | ||
|
|
||
| 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'), | ||
| ] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,67 @@ | ||
| from django.shortcuts import render | ||
| from .models import Notice | ||
| from .forms import NoticeForm | ||
| from leave_manager.common.routes import get_formatted_routes, get_routes, is_leave_issuer | ||
| from django.urls import reverse | ||
| from django.http import HttpResponseRedirect | ||
| from mobile_api.common.fcm import fcm | ||
| from leave_manager.common import check_leave_admin | ||
|
|
||
| # Create your views here. | ||
|
|
||
| def create_notice(request): | ||
| if not request.user.is_authenticated: | ||
| return HttpResponseRedirect(reverse('user-login')) | ||
| if not is_leave_issuer(request.user): | ||
| return HttpResponseRedirect(reverse('leave_manager_dashboard')) | ||
|
|
||
| context = {} | ||
| routes = get_formatted_routes(get_routes(request.user), active_page = "notice") | ||
| context.update({'routes':routes}) | ||
|
|
||
| if request.method == "POST": | ||
| form = NoticeForm(request.POST) | ||
| if form.is_valid(): | ||
| notice = form.save(commit=True) | ||
| fcm(None,notice,"notice") | ||
| return HttpResponseRedirect(reverse('notice-board')) | ||
| else: | ||
| context.update({'form':form}) | ||
| return render(request, 'department/notice.html', context=context) | ||
| else: | ||
| form = NoticeForm() | ||
| context.update({'form':form}) | ||
|
|
||
| return render(request, 'department/notice.html', context=context) | ||
|
|
||
|
|
||
|
|
||
| def get_notice(request): | ||
| if not request.user.is_authenticated: | ||
| return HttpResponseRedirect(reverse('user-login')) | ||
| context = {} | ||
| routes = get_formatted_routes(get_routes(request.user), active_page = "notice board") | ||
| context.update({'routes':routes}) | ||
| notice = Notice.objects.all() | ||
| context.update({'notices':notice}) | ||
| if check_leave_admin.is_leave_issuer(request.user): | ||
| context.update({'leave_issuer':1}) | ||
| return render(request, 'department/noticeboard.html', context=context) | ||
|
|
||
|
|
||
| def delete_notice(request,id): | ||
| if not request.user.is_authenticated: | ||
| return HttpResponseRedirect(reverse('user-login')) | ||
| context = {} | ||
| routes = get_formatted_routes(get_routes(request.user), active_page = "notice board") | ||
| context.update({'routes':routes}) | ||
| notice = Notice.objects.all() | ||
| context.update({'notices':notice}) | ||
| try: | ||
| notice = Notice.objects.get(id=id) | ||
| notice.delete() | ||
| except (Notice.DoesNotExists, Exception) as e: | ||
| print(e) | ||
| context.update({'message':'Notice Not Deleted'}) | ||
| return render(request, 'department/noticeboard.html', context=context) | ||
| return HttpResponseRedirect(reverse('notice-board')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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