def value_txt_report(year_number, month_number, group="all"): start_date = munge_date(year=year_number, month=month_number, day=1) start_date = make_start_date(date=start_date) start_date, end_date = month_range(start_date) rg = ReportGroup(group, Kard.objects.done()) done = rg.queryset cards = done.filter(done_date__gte=start_date, done_date__lte=end_date).order_by('-done_date') cards = [c for c in cards if c.is_card] context = { 'title': "Completed Value Cards", 'cards': cards, 'start_date': start_date, 'end_date': end_date, 'updated_at': datetime.datetime.now(), 'version': VERSION, } response = make_response(render_template('done-report.txt', **context)) response.headers['Content-Type'] = "text/plain" return response
def done_in_week(self, year=None, month=None, day=None, date=None): """ Kards that were completed in the week of the specified day. """ if not date: date = munge_date(year, month, day) date = make_end_date(date=date) start_date, end_date = week_range(date) results = self.done().filter(done_date__lte=date, done_date__gte=start_date) return results
def done_in_month(self, year=None, month=None, day=None, date=None): """ Kards that have been completed in the specified month. """ if not date: date = munge_date(year=year, month=month, day=day) date = make_end_date(date=date) start_date, faux_end_date = month_range(date) results = self.done().filter(done_date__lte=date, done_date__gte=start_date) return results