From 0d9832ddea1bab497674ffcb81503dbc98b014d9 Mon Sep 17 00:00:00 2001 From: luxagraf Date: Thu, 20 Jul 2023 10:01:40 -0500 Subject: posts: added a status to notes --- app/posts/migrations/0012_note_status.py | 18 ++++++++++++++++++ app/posts/models.py | 10 ++++++++++ app/posts/templates/posts/note_form.html | 2 +- app/posts/templates/posts/post_detail.html | 3 ++- app/posts/views.py | 2 +- 5 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 app/posts/migrations/0012_note_status.py diff --git a/app/posts/migrations/0012_note_status.py b/app/posts/migrations/0012_note_status.py new file mode 100644 index 0000000..a773488 --- /dev/null +++ b/app/posts/migrations/0012_note_status.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.2 on 2023-07-20 13:49 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('posts', '0011_alter_note_url'), + ] + + operations = [ + migrations.AddField( + model_name='note', + name='status', + field=models.IntegerField(choices=[(0, 'Need to Call In'), (1, 'Called In'), (2, 'Testing'), (3, 'Done'), (4, 'Live')], default=0), + ), + ] diff --git a/app/posts/models.py b/app/posts/models.py index 8781bc1..d9a4236 100644 --- a/app/posts/models.py +++ b/app/posts/models.py @@ -98,6 +98,14 @@ class Note(models.Model): body_markdown = models.TextField(blank=True, null=True) date_created = models.DateTimeField(default=timezone.now) post = models.ForeignKey(Post, on_delete=models.CASCADE, null=True) + STATUS = ( + (0, 'Call In'), + (1, 'Coming'), + (2, 'Testing'), + (3, 'Done'), + (4, 'Live'), + ) + status = models.IntegerField(choices=STATUS, default=0) class Meta: ordering = ('date_created',) @@ -108,6 +116,8 @@ class Note(models.Model): def get_absolute_url(self): return reverse('notes:edit', kwargs={"pk": self.pk}) + def save(self, *args, **kwargs): + super(Note, self).save() #URL,This Article,Type,Lead,Previous Leads,Other Testers,Notes/Docs,Last Pub Date,Update Next,Months Since Update,Update Frequency (Months),Updates per year,Prev. Updates,"18 Mo Traffic Trend ''' row[0] #url diff --git a/app/posts/templates/posts/note_form.html b/app/posts/templates/posts/note_form.html index 15797f2..10d81ac 100644 --- a/app/posts/templates/posts/note_form.html +++ b/app/posts/templates/posts/note_form.html @@ -5,7 +5,7 @@ {% for field in form %}
- {%if field.name == "post"%}{{field.label_tag}}{%else%}{{field.label_tag}}{%endif%} + {%if field.name == "post" or field.name == "status" %}{{field.label_tag}}{%else%}{{field.label_tag}}{%endif%} {%if field.name == "body_markdown"%}
{{ field }}
{%else%}{{field}}{%endif%}
{% if field.errors %}{{field.errors}}{% endif %} diff --git a/app/posts/templates/posts/post_detail.html b/app/posts/templates/posts/post_detail.html index 8117fe6..193cfa5 100644 --- a/app/posts/templates/posts/post_detail.html +++ b/app/posts/templates/posts/post_detail.html @@ -8,7 +8,8 @@
{% for object in object.note_set.all%} +

{{object.body_markdown}}

+

Status: {% if object.status == 0 %}{{object.get_status_display}}{%else%}{{object.get_status_display}}{%endif%}

{% endfor%}
{% endblock %} diff --git a/app/posts/views.py b/app/posts/views.py index ae8b1e4..e1af9b5 100644 --- a/app/posts/views.py +++ b/app/posts/views.py @@ -38,7 +38,7 @@ class NoteCreateView(CreateView): class NoteUpdateView(UpdateView): model = Note - fields = ['title', 'url', 'body_markdown', 'post'] + fields = ['title', 'url', 'body_markdown', 'post', 'status'] def get_context_data(self, **kwargs): context = super(NoteUpdateView, self).get_context_data(**kwargs) -- cgit v1.2.3-70-g09d2