diff --git a/hypha/apply/activity/messaging.py b/hypha/apply/activity/messaging.py index d2c7b76cbd78218fdb53d1af1193f0f26d5124d8..309b5829a9a6dbe8e3523e3a5bcb2ef6adc23cab 100644 --- a/hypha/apply/activity/messaging.py +++ b/hypha/apply/activity/messaging.py @@ -68,6 +68,7 @@ neat_related = { MESSAGES.SKIPPED_REPORT: 'report', MESSAGES.REPORT_FREQUENCY_CHANGED: 'config', MESSAGES.REPORT_NOTIFY: 'report', + MESSAGES.CREATED_REMINDER: 'reminder', } @@ -838,6 +839,7 @@ class DjangoMessagesAdapter(AdapterBase): MESSAGES.REMOVE_DOCUMENT: 'Successfully removed document', MESSAGES.SKIPPED_REPORT: 'handle_skipped_report', MESSAGES.REPORT_FREQUENCY_CHANGED: 'handle_report_frequency', + MESSAGES.CREATED_REMINDER: 'Reminder created', } def batch_reviewers_updated(self, added, sources, **kwargs): diff --git a/hypha/apply/activity/options.py b/hypha/apply/activity/options.py index c6b54450a0f2574c210c78c1a020b0021c23d48d..0e139c91bcd53da6071c6705e77beae11eae7ce3 100644 --- a/hypha/apply/activity/options.py +++ b/hypha/apply/activity/options.py @@ -46,6 +46,7 @@ class MESSAGES(Enum): SKIPPED_REPORT = 'Skipped Report' REPORT_FREQUENCY_CHANGED = 'Report Frequency Changed' REPORT_NOTIFY = 'Report Notify' + CREATED_REMINDER = 'CREATED_REMINDER' @classmethod def choices(cls): diff --git a/hypha/apply/funds/forms.py b/hypha/apply/funds/forms.py index 6827b9ef4d19af993a7a51a8671290c171f0bec0..22ebd890638aee18f40bf449d7dbb331b49803c6 100644 --- a/hypha/apply/funds/forms.py +++ b/hypha/apply/funds/forms.py @@ -411,10 +411,24 @@ class UpdateMetaTermsForm(ApplicationSubmissionModelForm): class CreateReminderForm(forms.ModelForm): - def __init__(self, user=None, *args, **kwargs): - self.user = user + submission = forms.ModelChoiceField( + queryset=ApplicationSubmission.objects.filter(), + widget=forms.HiddenInput(), + ) + time = forms.DateTimeField(input_formats=['%Y-%m-%dT%H:%M']) + + def __init__(self, instance=None, user=None, *args, **kwargs): super().__init__(*args, **kwargs) + self.user = user + + if instance: + self.fields['submission'].initial = instance.id + def save(self, *args, **kwargs): + return Reminder.objects.create( + time=self.cleaned_data['time'], + submission=self.cleaned_data['submission'], + user=self.user) class Meta: model = Reminder diff --git a/hypha/apply/funds/views.py b/hypha/apply/funds/views.py index 03fc6af293eb6aebaa0aec03529b8a79a9613f84..42735eb13ee56751ece6a5ef1e809373af53a733 100644 --- a/hypha/apply/funds/views.py +++ b/hypha/apply/funds/views.py @@ -588,21 +588,18 @@ class CreateReminderView(DelegatedViewMixin, CreateView): 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, - # ) + def form_valid(self, form): + response = super().form_valid(form) - # return response + messenger( + MESSAGES.CREATED_REMINDER, + request=self.request, + user=self.request.user, + source=self.object.submission, + related=self.object, + ) - # def get_success_url(self): - # return self.object.get_absolute_url() + return response class AdminSubmissionDetailView(ReviewContextMixin, ActivityContextMixin, DelegateableView, DetailView):