From 5faf66b787aa8176fbf925d93afab496780b8397 Mon Sep 17 00:00:00 2001 From: Vaibhav Mule <vaibhavmule135@gmail.com> Date: Sat, 14 Mar 2020 01:40:58 +0530 Subject: [PATCH] add create Reminder view --- hypha/apply/funds/forms.py | 13 +++++++++- hypha/apply/funds/models/__init__.py | 1 + hypha/apply/funds/models/reminders.py | 3 ++- .../applicationsubmission_admin_detail.html | 1 + .../templates/funds/includes/actions.html | 2 ++ .../funds/includes/create_reminder_form.html | 5 ++++ .../funds/templates/funds/reminder_form.html | 1 + hypha/apply/funds/views.py | 26 +++++++++++++++++++ 8 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 hypha/apply/funds/templates/funds/includes/create_reminder_form.html create mode 100644 hypha/apply/funds/templates/funds/reminder_form.html diff --git a/hypha/apply/funds/forms.py b/hypha/apply/funds/forms.py index 97a947897..6827b9ef4 100644 --- a/hypha/apply/funds/forms.py +++ b/hypha/apply/funds/forms.py @@ -11,7 +11,7 @@ from django_select2.forms import Select2Widget from hypha.apply.categories.models import MetaTerm from hypha.apply.users.models import User -from .models import ApplicationSubmission, AssignedReviewers, ReviewerRole +from .models import ApplicationSubmission, AssignedReviewers, ReviewerRole, Reminder from .utils import render_icon from .widgets import MetaTermSelect2Widget, Select2MultiCheckboxesWidget from .workflow import get_action_mapping @@ -408,3 +408,14 @@ class UpdateMetaTermsForm(ApplicationSubmissionModelForm): kwargs.pop('user') super().__init__(*args, **kwargs) self.fields['meta_terms'].queryset = MetaTerm.get_root_descendants().exclude(depth=2) + + +class CreateReminderForm(forms.ModelForm): + def __init__(self, user=None, *args, **kwargs): + self.user = user + super().__init__(*args, **kwargs) + + + class Meta: + model = Reminder + fields = ['time'] diff --git a/hypha/apply/funds/models/__init__.py b/hypha/apply/funds/models/__init__.py index 9b9fb053c..d7587ea55 100644 --- a/hypha/apply/funds/models/__init__.py +++ b/hypha/apply/funds/models/__init__.py @@ -5,6 +5,7 @@ from .forms import ApplicationForm from .reviewer_role import ReviewerRole from .screening import ScreeningStatus from .submissions import ApplicationRevision, ApplicationSubmission, AssignedReviewers +from .reminders import Reminder __all__ = ['ApplicationSubmission', 'AssignedReviewers', 'ApplicationRevision', 'ApplicationForm', 'ScreeningStatus', 'ReviewerRole'] diff --git a/hypha/apply/funds/models/reminders.py b/hypha/apply/funds/models/reminders.py index 6102f0ead..34cbbfd16 100644 --- a/hypha/apply/funds/models/reminders.py +++ b/hypha/apply/funds/models/reminders.py @@ -1,3 +1,4 @@ +from django.conf import settings from django.db import models @@ -15,7 +16,7 @@ class Reminder(models.Model): settings.AUTH_USER_MODEL, on_delete=models.PROTECT, ) - time = models.DateTimeField(verbose_name=_(' time')) + time = models.DateTimeField() action = models.CharField( choices=REMINDER_TYPES.items(), default='review', diff --git a/hypha/apply/funds/templates/funds/applicationsubmission_admin_detail.html b/hypha/apply/funds/templates/funds/applicationsubmission_admin_detail.html index 1b007bcbb..c7e1a704e 100644 --- a/hypha/apply/funds/templates/funds/applicationsubmission_admin_detail.html +++ b/hypha/apply/funds/templates/funds/applicationsubmission_admin_detail.html @@ -26,6 +26,7 @@ {% include "funds/includes/create_project_form.html" %} {% endif %} {% include "funds/includes/update_meta_terms_form.html" %} + {% include "funds/includes/create_reminder_form.html" %} {% endblock %} {% block flags %} diff --git a/hypha/apply/funds/templates/funds/includes/actions.html b/hypha/apply/funds/templates/funds/includes/actions.html index 20f84c073..fef520d40 100644 --- a/hypha/apply/funds/templates/funds/includes/actions.html +++ b/hypha/apply/funds/templates/funds/includes/actions.html @@ -28,3 +28,5 @@ <a class="button button--white button--full-width button--bottom-space" href="{% url 'funds:submissions:revisions:list' submission_pk=object.id %}">Revisions</a> <a data-fancybox data-src="#update-meta-terms" class="button button--white button--full-width button--bottom-space" href="#">Meta Terms</a> + +<a data-fancybox data-src="#create-reminder" class="button button--white button--full-width button--bottom-space" href="#">Create Reminder</a> diff --git a/hypha/apply/funds/templates/funds/includes/create_reminder_form.html b/hypha/apply/funds/templates/funds/includes/create_reminder_form.html new file mode 100644 index 000000000..89c39736a --- /dev/null +++ b/hypha/apply/funds/templates/funds/includes/create_reminder_form.html @@ -0,0 +1,5 @@ +<div class="modal" id="create-reminder"> + <h4 class="modal__header-bar">Create Reminder</h4> + {% include 'funds/includes/delegated_form_base.html' with form=reminder_form value='Create' %} +</div> + diff --git a/hypha/apply/funds/templates/funds/reminder_form.html b/hypha/apply/funds/templates/funds/reminder_form.html new file mode 100644 index 000000000..2f259b79a --- /dev/null +++ b/hypha/apply/funds/templates/funds/reminder_form.html @@ -0,0 +1 @@ +s \ No newline at end of file diff --git a/hypha/apply/funds/views.py b/hypha/apply/funds/views.py index 96bb65f9f..03fc6af29 100644 --- a/hypha/apply/funds/views.py +++ b/hypha/apply/funds/views.py @@ -53,6 +53,7 @@ from .forms import ( BatchProgressSubmissionForm, BatchUpdateReviewersForm, BatchUpdateSubmissionLeadForm, + CreateReminderForm, ProgressSubmissionForm, ScreeningSubmissionForm, UpdateMetaTermsForm, @@ -64,6 +65,7 @@ from .models import ( ApplicationRevision, ApplicationSubmission, LabBase, + Reminder, RoundBase, RoundsAndLabs, ) @@ -580,12 +582,36 @@ class UpdateMetaTermsView(DelegatedViewMixin, UpdateView): context_name = 'meta_terms_form' +@method_decorator(staff_required, name='dispatch') +class CreateReminderView(DelegatedViewMixin, CreateView): + context_name = 'reminder_form' + form_class = CreateReminderForm + model = Reminder + + # def form_valid(self, form): + # response = super().form_valid(form) + + # messenger( + # MESSAGES.CREATED_PROJECT, + # request=self.request, + # user=self.request.user, + # source=self.object, + # related=self.object.submission, + # ) + + # return response + + # def get_success_url(self): + # return self.object.get_absolute_url() + + class AdminSubmissionDetailView(ReviewContextMixin, ActivityContextMixin, DelegateableView, DetailView): template_name_suffix = '_admin_detail' model = ApplicationSubmission form_views = [ ProgressSubmissionView, ScreeningSubmissionView, + CreateReminderView, CommentFormView, UpdateLeadView, UpdateReviewersView, -- GitLab