usethesource: Allow comments to be attributed to non-account holders
This commit is contained in:
		
							parent
							
								
									296f29c84b
								
							
						
					
					
						commit
						9ff4682420
					
				
					 6 changed files with 25 additions and 4 deletions
				
			
		|  | @ -8,7 +8,7 @@ class CommentForm(forms.ModelForm): | |||
| 
 | ||||
|     class Meta: | ||||
|         model = Comment | ||||
|         fields = ['time', 'message', 'post_to_list'] | ||||
|         fields = ['time', 'attribute_to', 'message', 'post_to_list'] | ||||
| 
 | ||||
|     def __init__(self, *args, **kwargs): | ||||
|         super().__init__(*args, **kwargs) | ||||
|  |  | |||
|  | @ -0,0 +1,18 @@ | |||
| # Generated by Django 3.2.19 on 2024-03-15 03:43 | ||||
| 
 | ||||
| from django.db import migrations, models | ||||
| 
 | ||||
| 
 | ||||
| class Migration(migrations.Migration): | ||||
| 
 | ||||
|     dependencies = [ | ||||
|         ('usethesource', '0007_candidate_show_download_disclaimer'), | ||||
|     ] | ||||
| 
 | ||||
|     operations = [ | ||||
|         migrations.AddField( | ||||
|             model_name='comment', | ||||
|             name='attribute_to', | ||||
|             field=models.CharField(blank=True, max_length=50), | ||||
|         ), | ||||
|     ] | ||||
|  | @ -41,6 +41,7 @@ class Comment(models.Model): | |||
| 
 | ||||
|     candidate = models.ForeignKey(Candidate, on_delete=models.CASCADE) | ||||
|     user = models.ForeignKey(User, on_delete=models.PROTECT) | ||||
|     attribute_to = models.CharField(max_length=50, blank=True) | ||||
|     time = models.DateTimeField(default=timezone.now) | ||||
|     message = models.TextField() | ||||
|     email_message_id = models.CharField(max_length=255, default=gen_message_id) | ||||
|  |  | |||
|  | @ -1,6 +1,7 @@ | |||
| <form hx-target="this" hx-swap="outerHTML" hx-post="{% url 'usethesource:add_comment' slug=candidate.slug %}"> | ||||
|   {% csrf_token %} | ||||
|   <div>{{ form.time }}</div> | ||||
|   <div><label>Time: {{ form.time }}</label></div> | ||||
|   <div class="mt2"><label>Attribute to: {{ form.attribute_to }}</label></div> | ||||
|   <div class="mt2">{{ form.message }}</div> | ||||
|   <div class="mt2"><label>{{ form.post_to_list }} Post to the mailing list</div> | ||||
|   <div class="mt2"> | ||||
|  |  | |||
|  | @ -1,4 +1,4 @@ | |||
| <div class="mb4" hx-target="this" hx-swap="outerHTML"><strong>{{ comment.user }} — {{ comment.time }}</strong> | ||||
| <div class="mb4" hx-target="this" hx-swap="outerHTML"><strong>{% if comment.attribute_to %}{{ comment.attribute_to }}{% else %}{{ comment.user }}{% endif %} — {{ comment.time }}</strong> | ||||
|   {% if user.is_staff %} | ||||
|     <a href="#" class="f7 white bg-light-silver ph2" hx-get="{% url 'usethesource:edit_comment' comment_id=comment.id %}">edit</a> | ||||
|     <a href="#" class="f7 white bg-light-red ph2" hx-delete="{% url 'usethesource:delete_comment' comment_id=comment.id show_add='false' %}" hx-confirm="Are you sure you want to delete this comment?">delete</a> | ||||
|  |  | |||
|  | @ -1,6 +1,7 @@ | |||
| <form class="mb3" hx-target="this" hx-swap="outerHTML" hx-post="{% url 'usethesource:edit_comment' comment_id=comment.id %}"> | ||||
|   {% csrf_token %} | ||||
|   <div>{{ form.time }}</div> | ||||
|   <div><label>Time: {{ form.time }}</label></div> | ||||
|   <div class="mt2"><label>Attribute to: {{ form.attribute_to }}</label></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> | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue