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

Remove status_name as a field and access workflow dynamically

parent a9ccf139
No related branches found
No related tags found
No related merge requests found
...@@ -5,11 +5,12 @@ from opentech.apply.funds.models import ApplicationSubmission ...@@ -5,11 +5,12 @@ from opentech.apply.funds.models import ApplicationSubmission
class DashboardTable(tables.Table): class DashboardTable(tables.Table):
submit_time = tables.DateColumn(verbose_name="Submitted") submit_time = tables.DateColumn(verbose_name="Submitted")
status_name = tables.Column(verbose_name="Status") status_name = tables.Column(verbose_name="Status")
stage = tables.Column(verbose_name="Type")
page = tables.Column(verbose_name="Fund") page = tables.Column(verbose_name="Fund")
class Meta: class Meta:
model = ApplicationSubmission model = ApplicationSubmission
fields = ('title', 'status_name', 'page', 'round', 'submit_time', 'user') fields = ('title', 'status_name', 'stage', 'page', 'round', 'submit_time', 'user')
template = "dashboard/tables/table.html" template = "dashboard/tables/table.html"
def render_user(self, value): def render_user(self, value):
......
# -*- coding: utf-8 -*-
# Generated by Django 1.11.8 on 2018-02-14 12:08
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('funds', '0021_rename_workflow_field'),
]
operations = [
migrations.AddField(
model_name='applicationsubmission',
name='status_name',
field=models.CharField(default='', max_length=50),
preserve_default=False,
),
]
...@@ -438,10 +438,21 @@ class ApplicationSubmission(WorkflowHelpers, AbstractFormSubmission): ...@@ -438,10 +438,21 @@ class ApplicationSubmission(WorkflowHelpers, AbstractFormSubmission):
# Workflow inherited from WorkflowHelpers # Workflow inherited from WorkflowHelpers
status = models.CharField(max_length=254) status = models.CharField(max_length=254)
status_name = models.CharField(max_length=50)
objects = JSONOrderable.as_manager() objects = JSONOrderable.as_manager()
@property
def status_name(self):
return self.phase.name
@property
def stage(self):
return self.phase.stage
@property
def phase(self):
return self.workflow.current(self.status)
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
if not self.id: if not self.id:
# We are creating the object default to first stage # We are creating the object default to first stage
...@@ -452,8 +463,6 @@ class ApplicationSubmission(WorkflowHelpers, AbstractFormSubmission): ...@@ -452,8 +463,6 @@ class ApplicationSubmission(WorkflowHelpers, AbstractFormSubmission):
self.workflow_name = self.page.workflow_name self.workflow_name = self.page.workflow_name
self.status = str(self.workflow.first()) self.status = str(self.workflow.first())
# Ensure the display value is up to date
self.status_name = self.workflow.current(self.status).name
return super().save(*args, **kwargs) return super().save(*args, **kwargs)
def get_data(self): def get_data(self):
......
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