Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
raftmsohani committed Sep 27, 2023
1 parent 9363f04 commit fe08110
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
17 changes: 7 additions & 10 deletions tdrs-backend/tdpservice/data_files/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
DOMAIN = settings.FRONTEND_BASE_URL

class DataFileSummaryStatusFilter(admin.SimpleListFilter):
"""Admin class filter for file status (accepted, rejected) for datafile model"""
"""Admin class filter for file status (accepted, rejected) for datafile model."""

title = 'status'
parameter_name = 'status'
Expand Down Expand Up @@ -46,9 +46,8 @@ def lookups(self, request, model_admin):
def queryset(self, request, queryset):
"""Return a queryset."""
if self.value():
query_set_ids = [df.id for df in queryset if df.prog_type==self.value()]
query_set_ids = [df.id for df in queryset if df.prog_type == self.value()]
return queryset.filter(id__in=query_set_ids)
#return queryset.filter(prog_type=self.value())
else:
return queryset

Expand All @@ -65,33 +64,31 @@ def case_totals(self, obj):
return DataFileSummary.objects.get(datafile=obj).case_aggregates

def error_report_link(self, obj):
#Return the link to the error report.
"""Return the link to the error report."""
pe_len = ParserError.objects.filter(file=obj).count()

filtered_parserror_list_url = f'{DOMAIN}/admin/parsers/parsererror/?file=' + str(obj.id)
# have to find the error id from obj
return format_html("<a href='{url}'>{field}</a>",
field = 'Parser Error List: ' + str(pe_len) + " errors",
field='Parser Error List: ' + str(pe_len) + " errors",
url=filtered_parserror_list_url)

error_report_link.allow_tags = True

def data_file_summary(self, obj):
"""Return the data file summary."""
df = DataFileSummary.objects.get(datafile=obj)
return format_html("<a href='{url}'>{field}</a>",
field = f'{df.id}' + ":" + df.get_status(),
return format_html("<a href='{url}'>{field}</a>",
field=f'{df.id}' + ":" + df.get_status(),
url=f"{DOMAIN}/admin/parsers/datafilesummary/{df.id}/change/")


list_display = [
'id',
'stt',
'year',
'quarter',
'section',
'version',
#'status',
'data_file_summary',
'error_report_link',
]
Expand Down
2 changes: 1 addition & 1 deletion tdrs-backend/tdpservice/data_files/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ class Meta:
blank=False,
null=True
)

@property
def prog_type(self):
"""Return the program type for a given section."""
Expand All @@ -165,7 +166,6 @@ def prog_type(self):
# TODO: if given a datafile (section), we can reverse back to the program b/c the
# section string has "tribal/ssp" in it, then process of elimination we have tanf


@property
def filename(self):
"""Return the correct filename for this data file."""
Expand Down

0 comments on commit fe08110

Please sign in to comment.