Skip to content
This repository was archived by the owner on Aug 26, 2024. It is now read-only.

Commit ef0c53e

Browse files
Merge pull request #491 from diwash007/auto-name
auto add names for timelines based on check-in or blog post
2 parents 9bc533a + 3d70edd commit ef0c53e

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

gsoc/forms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class Meta:
5151
class BlogPostDueDateForm(forms.ModelForm):
5252
class Meta:
5353
model = BlogPostDueDate
54-
fields = ("title", "date", "category")
54+
fields = ("category", "date", "title")
5555

5656

5757
class EventForm(forms.ModelForm):

gsoc/models.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ class BlogPostDueDate(models.Model):
663663
class Meta:
664664
ordering = ["date"]
665665

666-
title = models.CharField(max_length=100, default="Weekly Blog Post Due")
666+
title = models.CharField(max_length=100, default="Loading...")
667667
date = models.DateField()
668668
timeline = models.ForeignKey(
669669
Timeline,
@@ -784,6 +784,18 @@ def save(self, *args, **kwargs):
784784
post2.save()
785785
except Exception:
786786
pass
787+
788+
# update title
789+
gsoc_year = GsocYear.objects.latest('gsoc_year')
790+
timeline = Timeline.objects.get(gsoc_year=gsoc_year)
791+
items = BlogPostDueDate.objects.filter(timeline=timeline)
792+
if self.category == 0:
793+
num = sum([1 for item in items if "Weekly Check-in Due" in item.title])
794+
self.title = f"Weekly Check-in Due {num}"
795+
else:
796+
num = sum([1 for item in items if "Weekly Blog Post Due" in item.title])
797+
self.title = f"Weekly Blog Post Due {num}"
798+
787799
super(BlogPostDueDate, self).save(*args, **kwargs)
788800

789801

0 commit comments

Comments
 (0)