From 8b7e7bd7672d83f909c4f6e99613f455bce3156d Mon Sep 17 00:00:00 2001
From: Todd Dembrey <todd.dembrey@torchbox.com>
Date: Fri, 2 Mar 2018 15:20:48 +0000
Subject: [PATCH] change Activity type to action

---
 opentech/apply/activity/models.py | 23 +++++++++++------------
 opentech/apply/activity/views.py  |  2 +-
 opentech/apply/funds/views.py     |  2 +-
 3 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/opentech/apply/activity/models.py b/opentech/apply/activity/models.py
index 405c70cb5..ae0acc114 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 124df88ac..881b1f1b8 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 4e260f735..2867c82a4 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}'
-- 
GitLab