From af709b080c431254395803e6531abe42fe678fc1 Mon Sep 17 00:00:00 2001 From: dfeng678 Date: Sun, 7 Nov 2021 17:49:53 -0500 Subject: [PATCH 1/3] initial changes to allow users to comment on their applications, may still need to check that a user is commenting only on their own application --- app/views.py | 16 +++++++++++----- penncfa/templates/app/application-show.html | 10 ++++------ .../templates/app/templatetags/application.html | 6 ++++-- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/app/views.py b/app/views.py index 520fc6ba..57a4e3d7 100644 --- a/app/views.py +++ b/app/views.py @@ -247,6 +247,7 @@ def event_new(request): @requester_only @require_http_methods(["GET", "POST"]) def event_edit(request, event_id): + user = request.user event = Event.objects.get(pk=event_id) if event.over: return redirect('event-show', event_id) @@ -254,6 +255,11 @@ def event_edit(request, event_id): form = EventForm(request.POST, instance=event) if form.is_valid(): try: + if request.POST.get('new-comment'): + messages.success(request, "Saved comment!") + comment = Comment(comment=request.POST['new-comment'], + funder=user.profile, event=event) + comment.save() with transaction.atomic(): event = form.save() save_from_form(event, request.POST) @@ -279,6 +285,11 @@ def event_show(request, event_id): user = request.user event = Event.objects.get(pk=event_id) if request.method == 'POST': # TODO: should really be PUT + if request.POST.get('new-comment'): + messages.success(request, "Saved comment!") + comment = Comment(comment=request.POST['new-comment'], + funder=user.profile, event=event) + comment.save() if user.profile.is_funder: grants = [] for item in event.item_set.all(): @@ -312,11 +323,6 @@ def event_show(request, event_id): user.profile.notify_osa(event, grants) except smtplib.SMTPException: pass - if request.POST.get('new-comment'): - messages.success(request, "Saved comment!") - comment = Comment(comment=request.POST['new-comment'], - funder=user.profile, event=event) - comment.save() return redirect('event-show', event_id) else: return redirect(EVENTS_HOME) diff --git a/penncfa/templates/app/application-show.html b/penncfa/templates/app/application-show.html index 701aa0b1..e57d41e0 100644 --- a/penncfa/templates/app/application-show.html +++ b/penncfa/templates/app/application-show.html @@ -39,20 +39,18 @@ {% application user event None %}
- {% if user and user.profile.is_funder %}

To submit your funding changes and any comments, click "Save."
To share a read-only copy of this application, click "Share."

Cancel - Share + {% if user and user.profile.is_funder %} -
- {% else %} -
+ Share + {% else %} Done + {% endif %}
- {% endif %}
diff --git a/penncfa/templates/app/templatetags/application.html b/penncfa/templates/app/templatetags/application.html index b4d7e317..6b4e97c1 100644 --- a/penncfa/templates/app/templatetags/application.html +++ b/penncfa/templates/app/templatetags/application.html @@ -234,9 +234,11 @@

{% empty %} There are no comments yet. {% endfor %} - {% if user.profile.is_funder %} + {% if user and user.profile.is_funder %}

Specify any conditions and stipulations here.

- + {% else %} +

Leave a comment for your funder here.

{% endif %} + From 996025b912298e08c66e7275481d3259f8aebaec Mon Sep 17 00:00:00 2001 From: dfeng678 Date: Sun, 14 Nov 2021 13:00:25 -0500 Subject: [PATCH 2/3] comment box only should only appear for the requester of an event --- penncfa/templates/app/templatetags/application.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/penncfa/templates/app/templatetags/application.html b/penncfa/templates/app/templatetags/application.html index 6b4e97c1..66d807e3 100644 --- a/penncfa/templates/app/templatetags/application.html +++ b/penncfa/templates/app/templatetags/application.html @@ -234,11 +234,13 @@

{% empty %} There are no comments yet. {% endfor %} + {% if user == event.requester.user %} {% if user and user.profile.is_funder %}

Specify any conditions and stipulations here.

{% else %}

Leave a comment for your funder here.

{% endif %} + {% endif %} From 21e2fa827f903841c23dd4a3e0d9f7f0d202c3cd Mon Sep 17 00:00:00 2001 From: dfeng678 Date: Sun, 14 Nov 2021 13:33:35 -0500 Subject: [PATCH 3/3] comment box shows up for funders --- penncfa/templates/app/templatetags/application.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/penncfa/templates/app/templatetags/application.html b/penncfa/templates/app/templatetags/application.html index 66d807e3..bbaeec86 100644 --- a/penncfa/templates/app/templatetags/application.html +++ b/penncfa/templates/app/templatetags/application.html @@ -234,7 +234,7 @@

{% empty %} There are no comments yet. {% endfor %} - {% if user == event.requester.user %} + {% if user == event.requester.user or user.profile.is_funder %} {% if user and user.profile.is_funder %}

Specify any conditions and stipulations here.

{% else %}