@ -5,6 +5,7 @@ from django.db.models import Q
|
||||
from app import settings
|
||||
|
||||
from core.forms.common import CommonModelForm
|
||||
from core.templatetags.markdown import to_duration
|
||||
|
||||
from project_management.models.projects import Project
|
||||
|
||||
@ -64,7 +65,9 @@ class DetailForm(ProjectForm):
|
||||
"right": [
|
||||
'planned_start_date',
|
||||
'planned_finish_date',
|
||||
'real_start_date',
|
||||
'real_finish_date',
|
||||
'duration'
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -120,6 +123,12 @@ class DetailForm(ProjectForm):
|
||||
initial = self.instance.modified,
|
||||
)
|
||||
|
||||
self.fields['duration'] = forms.IntegerField(
|
||||
label = 'Duration',
|
||||
disabled = True,
|
||||
initial = to_duration(self.instance.duration_project),
|
||||
)
|
||||
|
||||
self.fields['resources'] = forms.CharField(
|
||||
label = 'Available Resources',
|
||||
disabled = True,
|
||||
|
@ -105,6 +105,25 @@ class Project(ProjectCommonFieldsName):
|
||||
return self.name
|
||||
|
||||
|
||||
@property
|
||||
def duration_project(self) -> int:
|
||||
|
||||
duration_project: int = 0
|
||||
|
||||
from core.models.ticket.ticket import Ticket
|
||||
|
||||
tickets = Ticket.objects.filter(
|
||||
project = self.id
|
||||
)
|
||||
|
||||
for ticket in tickets:
|
||||
|
||||
duration_project = duration_project + int(ticket.duration_ticket)
|
||||
|
||||
|
||||
return int(duration_project)
|
||||
|
||||
|
||||
@property
|
||||
def percent_completed(self) -> str: # Auto-Calculate
|
||||
""" How much of the project is completed.
|
||||
|
Reference in New Issue
Block a user