Skip to content
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

Allow users and funders to comment back and forth on their applications #304

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,19 @@ 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)
if request.method == 'POST':
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)
Expand All @@ -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():
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 4 additions & 6 deletions penncfa/templates/app/application-show.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,18 @@
{% application user event None %}

<div class="d-print-none">
{% if user and user.profile.is_funder %}
<p>To submit your funding changes and any comments, click "Save." <br>
To share a read-only copy of this application, click "Share."</p>
<div class="form-group">
<a class="btn btn-secondary" href="{% url 'events' %}">Cancel</a>
<button class="btn btn-primary ml-1" type="submit" name="submit">Save</button>
<a class="btn btn-info ml-1" href="#" data-target="#share" data-toggle="modal">Share</a>
{% if user and user.profile.is_funder %}
<button id="no-fund" class="btn btn-danger ml-1" type="submit" name="submit">Do Not Fund</button>
</div>
{% else %}
<div class="form-group">
<a class="btn btn-info ml-1" href="#" data-target="#share" data-toggle="modal">Share</a>
{% else %}
<a class="btn btn-primary" href="{% url 'events' %}">Done</a>
{% endif %}
</div>
{% endif %}
</div>
</form>
</div>
Expand Down
8 changes: 6 additions & 2 deletions penncfa/templates/app/templatetags/application.html
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,13 @@ <h2>
{% empty %}
There are no comments yet.
{% endfor %}
{% if user.profile.is_funder %}
{% if user == event.requester.user or user.profile.is_funder %}
{% if user and user.profile.is_funder %}
<p>Specify any conditions and stipulations here.</p>
<textarea name="new-comment" class="span8 form-control"></textarea>
{% else %}
<p>Leave a comment for your funder here.</p>
{% endif %}
<textarea name="new-comment" class="span8 form-control"></textarea>
{% endif %}
</div>
</section>