diff --git a/opentech/apply/activity/models.py b/opentech/apply/activity/models.py index 405c70cb5e886416efd64bb7263f9ec279c81c41..ae0acc1145982ecaa2a44d76c5c9a88153b17a2b 100644 --- a/opentech/apply/activity/models.py +++ b/opentech/apply/activity/models.py @@ -2,30 +2,29 @@ from django.conf import settings from django.db import models COMMENT = 'comment' -ACTIVITY = 'activity' +ACTION = 'action' ACTIVITY_TYPES = { COMMENT: 'Comment', - ACTIVITY: 'Activity', + ACTION: 'Action', } -class CommentManger(models.Manager): +class ActivityBaseManager(models.Manager): def create(self, **kwargs): - kwargs.update(type=COMMENT) + kwargs.update(type=self.type) return super().create(**kwargs) def get_queryset(self): - return super().get_queryset().filter(type=COMMENT) + return super().get_queryset().filter(type=self.type) -class ActivityManager(models.Manager): - def create(self, **kwargs): - kwargs.update(type=ACTIVITY) - return super().create(**kwargs) +class CommentManger(ActivityBaseManager): + type = COMMENT - def get_queryset(self): - return super().get_queryset().filter(type=ACTIVITY) + +class ActionManager(ActivityBaseManager): + type = ACTION class Activity(models.Model): @@ -37,7 +36,7 @@ class Activity(models.Model): objects = models.Manager() comments = CommentManger() - activities = ActivityManager() + actions = ActionManager() class Meta: ordering = ['-timestamp'] diff --git a/opentech/apply/activity/views.py b/opentech/apply/activity/views.py index 124df88ac99cace721d451cddfea256fdd1bb49b..881b1f1b84a7415d9cd96d22a7d400422a5f5a1b 100644 --- a/opentech/apply/activity/views.py +++ b/opentech/apply/activity/views.py @@ -7,7 +7,7 @@ from .models import Activity, COMMENT class ActivityContextMixin: def get_context_data(self, **kwargs): extra = { - 'activity': Activity.activities.filter(submission=self.object), + 'actions': Activity.actions.filter(submission=self.object), 'comments': Activity.comments.filter(submission=self.object), CommentFormView.context_name: CommentFormView.form_class(), } diff --git a/opentech/apply/funds/views.py b/opentech/apply/funds/views.py index 4e260f735e9bc9a759e97cd376b57ed4330800ca..2867c82a47672e9c65627113b76b11553191691a 100644 --- a/opentech/apply/funds/views.py +++ b/opentech/apply/funds/views.py @@ -62,7 +62,7 @@ class ProgressSubmissionView(DelegatedViewMixin, UpdateView): old_phase = form.instance.phase.name response = super().form_valid(form) new_phase = form.instance.phase.name - Activity.activities.create( + Activity.actions.create( user=self.request.user, submission=self.kwargs['submission'], message=f'Progressed from {old_phase} to {new_phase}'