def calendar(request, username=None, year=None, month=None): ''' Show a calendar with all the workout logs ''' context = {} is_owner, user = check_access(request.user, username) year = int(year) if year else datetime.date.today().year month = int(month) if month else datetime.date.today().month (current_workout, schedule) = Schedule.objects.get_current_workout(user) grouped_log_entries = group_log_entries(user, year, month) context['calendar'] = WorkoutCalendar(grouped_log_entries).formatmonth( year, month) context['logs'] = grouped_log_entries context['current_year'] = year context['current_month'] = month context['current_workout'] = current_workout context['owner_user'] = user context['is_owner'] = is_owner context['impressions'] = WorkoutSession.IMPRESSION context['month_list'] = WorkoutLog.objects.filter(user=user).dates( 'date', 'month') context['show_shariff'] = is_owner and user.userprofile.ro_access return render(request, 'calendar/month.html', context)
def day(request, username, year, month, day): ''' Show the logs for a single day ''' context = {} is_owner, user = check_access(request.user, username) try: date = datetime.date(int(year), int(month), int(day)) except ValueError as e: logger.error("Error on date: {0}".format(e)) return HttpResponseForbidden() context['logs'] = group_log_entries(user, date.year, date.month, date.day) context['date'] = date context['owner_user'] = user context['is_owner'] = is_owner context['show_shariff'] = is_owner and user.userprofile.ro_access return render(request, 'calendar/day.html', context)
def day(request, username, year, month, day): """ Show the logs for a single day """ context = {} is_owner, user = check_access(request.user, username) try: date = datetime.date(int(year), int(month), int(day)) except ValueError as e: logger.error("Error on date: {0}".format(e)) return HttpResponseForbidden() context["logs"] = group_log_entries(user, date.year, date.month, date.day) context["date"] = date context["owner_user"] = user context["is_owner"] = is_owner context["show_shariff"] = is_owner and user.userprofile.ro_access return render(request, "calendar/day.html", context)
def calendar(request, username=None, year=None, month=None): """ Show a calendar with all the workout logs """ context = {} is_owner, user = check_access(request.user, username) year = int(year) if year else datetime.date.today().year month = int(month) if month else datetime.date.today().month (current_workout, schedule) = Schedule.objects.get_current_workout(user) grouped_log_entries = group_log_entries(user, year, month) context["calendar"] = WorkoutCalendar(grouped_log_entries).formatmonth(year, month) context["logs"] = grouped_log_entries context["current_year"] = year context["current_month"] = month context["current_workout"] = current_workout context["owner_user"] = user context["is_owner"] = is_owner context["impressions"] = WorkoutSession.IMPRESSION context["month_list"] = WorkoutLog.objects.filter(user=user).dates("date", "month") context["show_shariff"] = is_owner and user.userprofile.ro_access return render(request, "calendar/month.html", context)
def calendar(request, username=None, year=None, month=None): ''' Show a calendar with all the workout logs ''' context = {} is_owner, user = check_access(request.user, username) year = int(year) if year else datetime.date.today().year month = int(month) if month else datetime.date.today().month (current_workout, schedule) = Schedule.objects.get_current_workout(user) grouped_log_entries = group_log_entries(user, year, month) context['calendar'] = WorkoutCalendar(grouped_log_entries).formatmonth(year, month) context['logs'] = grouped_log_entries context['current_year'] = year context['current_month'] = month context['current_workout'] = current_workout context['owner_user'] = user context['is_owner'] = is_owner context['impressions'] = WorkoutSession.IMPRESSION context['month_list'] = WorkoutLog.objects.filter(user=user).dates('date', 'month') context['show_shariff'] = is_owner and user.userprofile.ro_access return render(request, 'calendar/month.html', context)