Source code for collecting_society_web.views.widgets.rejected_content

# For copyright and license terms, see COPYRIGHT.rst (top level of repository)
# Repository: https://github.com/C3S/collecting_society_web

from ...models import Content

from ...services import _


[docs] class RejectedContentWidget(): def __init__(self, request, category='all'): self.party = request.party.id self.template = '../../templates/widgets/rejected_content.pt' self.category = category
[docs] def condition(self): return self.badge() > 0
[docs] def icon(self): return "glyphicon glyphicon-ban-circle"
[docs] def header(self): return _("Rejected Content")
[docs] def dupl(self): return Content.search_rejects(self.party, 'dupl', self.category)
[docs] def ferrors(self): return Content.search_rejects(self.party, 'ferrors', self.category)
[docs] def lossyc(self): return Content.search_rejects(self.party, 'lossyc', self.category)
[docs] def description(self): return _("Total number of files you uploaded that where rejected")
[docs] def get_len(self, content_list): if content_list: return len(content_list) else: return 0
# def output(self): # dupl = self.get_len(self.dupl()) # ferrors = self.get_len(self.ferrors()) # lossyc = self.get_len(self.lossyc()) # rejects = dupl + ferrors + lossyc # output = render( # self.template, # { # 'dupl': dupl, # 'ferrors': ferrors, # 'lossyc': lossyc, # 'rejects': rejects # } # ) # return output
[docs] def badge(self): dupl = self.get_len(self.dupl()) ferrors = self.get_len(self.ferrors()) lossyc = self.get_len(self.lossyc()) rejects = dupl + ferrors + lossyc return rejects