diff --git a/conservancy/usethesource/forms.py b/conservancy/usethesource/forms.py index 3fb9755f39b2c74a7071ac2a56497506684d2e5d..9328b6d5a2d82ca0dd607febbb5eed119b3c95ff 100644 --- a/conservancy/usethesource/forms.py +++ b/conservancy/usethesource/forms.py @@ -6,7 +6,11 @@ from .models import Comment class CommentForm(forms.ModelForm): class Meta: model = Comment - fields = ['message'] + fields = ['time', 'message'] + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.fields['time'].widget.input_type = 'datetime-local' class DownloadForm(forms.Form): diff --git a/conservancy/usethesource/models.py b/conservancy/usethesource/models.py index 4f360dfee3b235f1b24925e388ee90297b93e72c..2edb1206fa10a10a3d0d8cc6a5fc1240ea1a2695 100644 --- a/conservancy/usethesource/models.py +++ b/conservancy/usethesource/models.py @@ -3,6 +3,7 @@ import uuid from django.contrib.auth.models import User from django.db import models from django.urls import reverse +from django.utils import timezone def gen_message_id(): @@ -39,7 +40,7 @@ class Comment(models.Model): candidate = models.ForeignKey(Candidate, on_delete=models.CASCADE) user = models.ForeignKey(User, on_delete=models.PROTECT) - time = models.DateTimeField(auto_now_add=True) + time = models.DateTimeField(default=timezone.now) message = models.TextField() email_message_id = models.CharField(max_length=255, default=gen_message_id) diff --git a/conservancy/usethesource/templates/usethesource/comment_form.html b/conservancy/usethesource/templates/usethesource/add_comment_form.html similarity index 65% rename from conservancy/usethesource/templates/usethesource/comment_form.html rename to conservancy/usethesource/templates/usethesource/add_comment_form.html index 7c62ee332c9275c58ba955ed8f5dec26ce5d4f0e..a3228f604b4afca0cf6750dbcfd3ba4bfe402683 100644 --- a/conservancy/usethesource/templates/usethesource/comment_form.html +++ b/conservancy/usethesource/templates/usethesource/add_comment_form.html @@ -1,8 +1,9 @@
{% csrf_token %} - {{ form.message }} +
{{ form.time }}
+
{{ form.message }}
- {% include 'usethesource/save_button_partial.html' %} +
diff --git a/conservancy/usethesource/templates/usethesource/candidate.html b/conservancy/usethesource/templates/usethesource/candidate.html index e4a20ca6a610502c604a70774ad06fad5f8dd460..3c50de9d6b6ac5d6f0ff036ea8620cdf6fa6f6aa 100644 --- a/conservancy/usethesource/templates/usethesource/candidate.html +++ b/conservancy/usethesource/templates/usethesource/candidate.html @@ -15,7 +15,7 @@

{{ candidate.name }}

- + {% if user.is_staff or user.is_superuser %}{% endif %}

Vendor: {{ candidate.vendor }}

@@ -37,7 +37,7 @@ {% endfor %} {% endwith %} - {% if user.is_staff %} + {% if user.is_staff or user.is_superuser %} {% include "usethesource/add_comment_button_partial.html" %} {% endif %} diff --git a/conservancy/usethesource/templates/usethesource/edit_comment_form.html b/conservancy/usethesource/templates/usethesource/edit_comment_form.html index 0bab29c445d163db241d24b9c78df8d14caa778a..9eb52cf5576a4bc86625dfaea446a12a193cc46b 100644 --- a/conservancy/usethesource/templates/usethesource/edit_comment_form.html +++ b/conservancy/usethesource/templates/usethesource/edit_comment_form.html @@ -1,8 +1,9 @@
{% csrf_token %} - {{ form.message }} +
{{ form.time }}
+
{{ form.message }}
- {% include 'usethesource/save_button_partial.html' %} +
diff --git a/conservancy/usethesource/templates/usethesource/save_button_partial.html b/conservancy/usethesource/templates/usethesource/save_button_partial.html deleted file mode 100644 index 5cc66948bab29498f9413f69f78c86e29321b82f..0000000000000000000000000000000000000000 --- a/conservancy/usethesource/templates/usethesource/save_button_partial.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/conservancy/usethesource/views.py b/conservancy/usethesource/views.py index 34bf684fc51502ba1a0e43d51a2d5fc1aeaebac1..0cdf0816be5da7bd859220fb0babd2427daa9578 100644 --- a/conservancy/usethesource/views.py +++ b/conservancy/usethesource/views.py @@ -46,7 +46,7 @@ def create_comment(request, slug): email = make_comment_email(comment) email.send() return redirect('usethesource:view_comment', comment_id=comment.id, show_add='true') - return render(request, 'usethesource/comment_form.html', {'form': form, 'candidate': candidate}) + return render(request, 'usethesource/add_comment_form.html', {'form': form, 'candidate': candidate}) @staff_member_required