Changeset - 2a23a0a55ea0
[Not reviewed]
conservancy/usethesource/forms.py
Show inline comments
...
 
@@ -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):
conservancy/usethesource/models.py
Show inline comments
...
 
@@ -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)
 

	
conservancy/usethesource/templates/usethesource/add_comment_form.html
Show inline comments
 
file renamed from conservancy/usethesource/templates/usethesource/comment_form.html to conservancy/usethesource/templates/usethesource/add_comment_form.html
 
<form hx-target="this" hx-swap="outerHTML" hx-post="{% url 'usethesource:add_comment' slug=candidate.slug %}">
 
  {% csrf_token %}
 
  {{ form.message }}
 
  <div>{{ form.time }}</div>
 
  <div class="mt2">{{ form.message }}</div>
 
  <div class="mt2">
 
    <button type="submit" hx-get="{% url 'usethesource:add_button' slug=candidate.slug %}" class="b pointer white bg-light-silver pv2 ph3" style="border: none">Cancel</button>
 
    {% include 'usethesource/save_button_partial.html' %}
 
    <button type="submit" class="b white bg-green pv2 ph3" style="border: none">Save and email</button>
 
  </div>
 
</form>
conservancy/usethesource/templates/usethesource/candidate.html
Show inline comments
...
 
@@ -15,7 +15,7 @@
 
      <div>
 
        <div class="flex items-center">
 
          <h2 class="f2 lh-title ttu mt0">{{ candidate.name }}</h2>
 
          <a href="{% url 'admin:usethesource_candidate_change' object_id=candidate.id %}" title="Edit candidate" class="f3 white bg-light-silver db ph2 mh2 mb3" style="transform: scaleX(-1); text-decoration: none !important">✎</a>
 
          {% if user.is_staff or user.is_superuser %}<a href="{% url 'admin:usethesource_candidate_change' object_id=candidate.id %}" title="Edit candidate" class="f3 white bg-light-silver db ph2 mh2 mb3" style="transform: scaleX(-1); text-decoration: none !important">✎</a>{% endif %}
 
        </div>
 

	
 
        <p><strong>Vendor</strong>: {{ candidate.vendor }}</p>
...
 
@@ -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 %}
 
  </section>
conservancy/usethesource/templates/usethesource/edit_comment_form.html
Show inline comments
 
<form class="mb3" hx-target="this" hx-swap="outerHTML" hx-post="{% url 'usethesource:edit_comment' comment_id=comment.id %}">
 
  {% csrf_token %}
 
  {{ form.message }}
 
  <div>{{ form.time }}</div>
 
  <div class="mt2">{{ form.message }}</div>
 
  <div class="mt2">
 
    <button type="submit" hx-get="{% url 'usethesource:view_comment' comment_id=comment.id show_add='false' %}" class="b pointer white bg-light-silver pv2 ph3" style="border: none">Cancel</button>
 
    {% include 'usethesource/save_button_partial.html' %}
 
    <button type="submit" class="b white bg-green pv2 ph3" style="border: none">Save</button>
 
  </div>
 
</form>
conservancy/usethesource/templates/usethesource/save_button_partial.html
Show inline comments
 
deleted file
conservancy/usethesource/views.py
Show inline comments
...
 
@@ -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
0 comments (0 inline, 0 general)