diff options
author | luxagraf <sng@luxagraf.net> | 2023-12-03 15:31:48 -0500 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2023-12-03 15:31:48 -0500 |
commit | b0e4081416bb7298015093779b6e3e6d98fa736e (patch) | |
tree | 54063fd231418ea62f87322ba6cdb5c168499935 /app/gtd | |
parent | 937775b28d30acd6557a824f4030f8d298c4ff59 (diff) |
gtd: added an updater for updating which guides need an update
Diffstat (limited to 'app/gtd')
-rw-r--r-- | app/gtd/migrations/0023_alter_gtdproject_project_type.py | 18 | ||||
-rw-r--r-- | app/gtd/migrations/0024_alter_gtdnote_status.py | 18 | ||||
-rw-r--r-- | app/gtd/migrations/0025_alter_wiredpost_post_status.py | 18 | ||||
-rw-r--r-- | app/gtd/models.py | 21 | ||||
-rw-r--r-- | app/gtd/templates/gtd/wiredpost_table.html | 1 | ||||
-rw-r--r-- | app/gtd/views.py | 7 |
6 files changed, 73 insertions, 10 deletions
diff --git a/app/gtd/migrations/0023_alter_gtdproject_project_type.py b/app/gtd/migrations/0023_alter_gtdproject_project_type.py new file mode 100644 index 0000000..b70183e --- /dev/null +++ b/app/gtd/migrations/0023_alter_gtdproject_project_type.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.7 on 2023-12-03 15:04 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('gtd', '0022_alter_gtdproject_project_type'), + ] + + operations = [ + migrations.AlterField( + model_name='gtdproject', + name='project_type', + field=models.IntegerField(choices=[(1, 'lbh'), (2, 'lxf'), (3, 'personal'), (4, 'bus')], default=3), + ), + ] diff --git a/app/gtd/migrations/0024_alter_gtdnote_status.py b/app/gtd/migrations/0024_alter_gtdnote_status.py new file mode 100644 index 0000000..887e4c5 --- /dev/null +++ b/app/gtd/migrations/0024_alter_gtdnote_status.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.7 on 2023-12-03 15:08 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('gtd', '0023_alter_gtdproject_project_type'), + ] + + operations = [ + migrations.AlterField( + model_name='gtdnote', + name='status', + field=models.SmallIntegerField(choices=[(0, 'None'), (1, 'Open'), (2, 'Completed')], default=0), + ), + ] diff --git a/app/gtd/migrations/0025_alter_wiredpost_post_status.py b/app/gtd/migrations/0025_alter_wiredpost_post_status.py new file mode 100644 index 0000000..790bd6f --- /dev/null +++ b/app/gtd/migrations/0025_alter_wiredpost_post_status.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.7 on 2023-12-03 15:26 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('gtd', '0024_alter_gtdnote_status'), + ] + + operations = [ + migrations.AlterField( + model_name='wiredpost', + name='post_status', + field=models.IntegerField(choices=[(0, 'Assigned'), (1, 'turned in'), (2, 'published'), (3, 'NEW')], default=2), + ), + ] diff --git a/app/gtd/models.py b/app/gtd/models.py index d309ac0..5a371d9 100644 --- a/app/gtd/models.py +++ b/app/gtd/models.py @@ -38,13 +38,11 @@ class GTDOutcome(models.Model): class GTDProject(models.Model): - WIRED = 0 LBH = 1 LXF = 2 PERSONAL = 3 BUS = 4 PROJECT_TYPE = ( - (WIRED, 'wired'), (LBH, 'lbh'), (LXF, 'lxf'), (PERSONAL, 'personal'), @@ -118,7 +116,7 @@ class GTDNote(models.Model): (OPEN, 'Open'), (COMPLETED, 'Completed'), ] - status = models.SmallIntegerField(choices=STATUS, default=OPEN) + status = models.SmallIntegerField(choices=STATUS, default=NONE) class Meta: ordering = ('-date_created',) @@ -150,7 +148,7 @@ class PostStatus(models.IntegerChoices): ASSIGNED = 0, ('Assigned') TURNEDIN = 1, ('turned in') PUBLISHED = 2, ('published') - + NEW = 3, ('NEW') class WiredPost(models.Model): # an entry in a feed @@ -179,11 +177,16 @@ class WiredPost(models.Model): td = datetime.date.today() - self.date_last_pub return int(td.days) - # def get_needs_update(self): - # if self.time_since_update() > self.update_frequency: - # return True - # else: - # return False + def set_needs_update(self): + if self.date_last_pub: + td = datetime.date.today() - self.date_last_pub + if self.post_status == 0 or 2 and td.days > self.update_frequency: + self.needs_update = True + self.save() + else: + self.needs_update = False + self.save() + return '' def days_overdue(self): if self.needs_update: diff --git a/app/gtd/templates/gtd/wiredpost_table.html b/app/gtd/templates/gtd/wiredpost_table.html index 92eac7e..8ea91e6 100644 --- a/app/gtd/templates/gtd/wiredpost_table.html +++ b/app/gtd/templates/gtd/wiredpost_table.html @@ -58,6 +58,7 @@ Date last pub <td class="field-needs_update">{% if object.needs_update %} <span class="hide">1</span><img src="/static/admin/img/icon-yes.svg" alt="True">{%else%} <span class="hide">0</span><img src="/static/admin/img/icon-no.svg" alt="False">{%endif%} + {{object.set_needs_update}} </td> <td class="field-days_overdue">{{object.days_overdue}}</td> <td class="field-days_overdue"><a href="{% url 'gtd:wiredpost-edit' object.pk %}">edit</a></td></tr> diff --git a/app/gtd/views.py b/app/gtd/views.py index bb11030..eaa14a6 100644 --- a/app/gtd/views.py +++ b/app/gtd/views.py @@ -76,12 +76,17 @@ class GTDNoteTODOView(ListView): template_name = "gtd/note_list.html" def get_queryset(self): + project = self.request.GET.get("project", False) # need to get wired notes and gtd notes and blend them by # date created maybe? - return GTDNote.objects.filter(status=1) + if project: + return GTDNote.objects.filter(status=1,note_type__in=[1,2],project__title=project) + return GTDNote.objects.filter(status=1,note_type__in=[1,2]) def get_context_data(self, **kwargs): context = super(GTDNoteTODOView, self).get_context_data(**kwargs) + context['projects'] = GTDProject.objects.all() + context['project'] = self.request.GET.get("project", False) return context |