Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove TimeCardObject.submitted #933

Merged
merged 3 commits into from
Dec 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions tock/hours/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ class TimecardObjectInline(admin.TabularInline):
formset = TimecardObjectFormset
model = TimecardObject
readonly_fields = [
'submitted',
'grade',
'revenue_profit_loss_account',
'expense_profit_loss_account'
Expand All @@ -80,7 +79,7 @@ class TimecardObjectInline(admin.TabularInline):

class TimecardAdmin(admin.ModelAdmin):
inlines = (TimecardObjectInline,)
list_display = ('user', 'reporting_period',)
list_display = ('user', 'reporting_period', 'submitted')
list_filter = (ReportingPeriodListFilter, 'reporting_period',)
search_fields = ['user__username', 'reporting_period__start_date', 'reporting_period__end_date',]

Expand Down
18 changes: 18 additions & 0 deletions tock/hours/migrations/0047_auto_20191204_0940.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.7 on 2019-12-04 14:40

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('projects', '0023_auto_20171229_1156'),
('hours', '0046_deferrable_unique'),
]

operations = [
migrations.RemoveField(
model_name='timecardobject',
name='submitted',
),
]
3 changes: 0 additions & 3 deletions tock/hours/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,6 @@ class TimecardObject(models.Model):
default='',
help_text='Please provide details about how you spent your time.'
)
submitted = models.BooleanField(default=False)
revenue_profit_loss_account = models.ForeignKey(
ProfitLossAccount,
blank=True,
Expand Down Expand Up @@ -373,8 +372,6 @@ def save(self, *args, **kwargs):
self.timecard.user
)

self.submitted = self.timecard.submitted

p_pl = self.project.profit_loss_account # Project PL info.
u_pl = self.timecard.user.user_data.profit_loss_account # User PL info.
rp = self.timecard.reporting_period # TimecardObject reporting period.
Expand Down
6 changes: 1 addition & 5 deletions tock/hours/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ def ReportingPeriodCSVView(request, reporting_period):

writer = csv.writer(response)
timecard_objects = TimecardObject.objects.filter(
timecard__reporting_period__start_date=reporting_period
timecard__reporting_period__start_date=reporting_period, timecard__submitted=True
).order_by(
'timecard__reporting_period__start_date'
).select_related(
Expand All @@ -764,10 +764,6 @@ def ReportingPeriodCSVView(request, reporting_period):
])

for timecard_object in timecard_objects:
# skip entries if timecard not submitted yet
if not timecard_object.timecard.submitted:
continue

writer.writerow(timecard_object.to_csv_row())

return response
Expand Down
2 changes: 0 additions & 2 deletions tock/projects/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,13 +494,11 @@ def test_total_hours_billed(self):
TimecardObject.objects.create(
timecard = Timecard.objects.get(pk=1),
project=Project.objects.get(pk=1),
submitted = True,
hours_spent= 10
)
TimecardObject.objects.create(
timecard = Timecard.objects.get(pk=2),
project=Project.objects.get(pk=1),
submitted = False,
Jkrzy marked this conversation as resolved.
Show resolved Hide resolved
hours_spent= 5
)

Expand Down
4 changes: 2 additions & 2 deletions tock/projects/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['table'] = project_timeline(kwargs['object'])
context['total_hours_submitted'] = TimecardObject.objects.filter(
project=kwargs['object'].id, submitted=True
project=kwargs['object'].id, timecard__submitted=True
).aggregate(Sum('hours_spent'))['hours_spent__sum'] or 0
context['total_hours_saved'] = TimecardObject.objects.filter(
project=kwargs['object'].id, submitted=False
project=kwargs['object'].id, timecard__submitted=False
).aggregate(Sum('hours_spent'))['hours_spent__sum'] or 0
context['total_hours_all'] = context['total_hours_submitted'] + context['total_hours_saved']
return context
Expand Down
Loading