Skip to content
Snippets Groups Projects
Commit 8b7e7bd7 authored by Todd Dembrey's avatar Todd Dembrey
Browse files

change Activity type to action

parent 984e6027
No related branches found
No related tags found
No related merge requests found
......@@ -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']
......
......@@ -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(),
}
......
......@@ -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}'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment