Initially working templates on back
parent
4c9b7dbcc5
commit
518c97d989
|
@ -46,6 +46,10 @@ class ProjectAdminViewSet(ModelCrudViewSet):
|
|||
def pre_save(self, obj):
|
||||
obj.owner = self.request.user
|
||||
|
||||
# TODO REFACTOR THIS
|
||||
if not obj.id:
|
||||
obj.template = self.request.QUERY_PARAMS['template']
|
||||
|
||||
# FIXME
|
||||
|
||||
# Assign domain only if it current
|
||||
|
|
|
@ -585,3 +585,8 @@ def project_post_save(sender, instance, created, **kwargs):
|
|||
obj.permissions.add(perm)
|
||||
|
||||
instance.save()
|
||||
|
||||
from taiga.projects.template_manager import ProjectTemplateManager
|
||||
if instance.template:
|
||||
template_manager = ProjectTemplateManager()
|
||||
template_manager.apply(instance.template, instance)
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
from taiga.projects.models import UserStoryStatus
|
||||
|
||||
class ProjectTemplateManager():
|
||||
def apply(self, template, project):
|
||||
if not hasattr(self, template):
|
||||
return False
|
||||
template = getattr(self, template)
|
||||
template(project)
|
||||
|
||||
def legal(self, project):
|
||||
pass
|
||||
|
||||
def pure_kanban(self, project):
|
||||
project.is_backlog_activated = False
|
||||
project.is_kanban_activated = True
|
||||
project.is_wiki_activated = False
|
||||
project.is_issues_activated = False
|
||||
project.save()
|
||||
|
||||
us_status = project.us_statuses.get(order=1)
|
||||
us_status.name = "To do"
|
||||
us_status.color = "#999999"
|
||||
us_status.save()
|
||||
|
||||
us_status = project.us_statuses.get(order=2)
|
||||
us_status.name = "Doing"
|
||||
us_status.color = "#ff9900"
|
||||
us_status.is_closed = False
|
||||
us_status.save()
|
||||
|
||||
us_status = UserStoryStatus()
|
||||
us_status.order = 3
|
||||
us_status.name = "Done"
|
||||
us_status.color = "#ffcc00"
|
||||
us_status.project = project
|
||||
us_status.is_closed = True
|
||||
us_status.save()
|
Loading…
Reference in New Issue