uncloud-mravi/uncloud_pay/helpers.py

27 lines
869 B
Python
Raw Normal View History

from functools import reduce
2020-02-29 08:08:30 +00:00
from datetime import datetime
from rest_framework import mixins
from rest_framework.viewsets import GenericViewSet
2020-02-29 08:08:30 +00:00
from django.utils import timezone
2020-03-01 14:47:27 +00:00
from calendar import monthrange
2020-03-01 14:47:27 +00:00
def beginning_of_month(year, month):
tz = timezone.get_current_timezone()
return datetime(year=year, month=month, day=1, tzinfo=tz)
def end_of_month(year, month):
(_, days) = monthrange(year, month)
tz = timezone.get_current_timezone()
return datetime(year=year, month=month, day=days,
hour=23, minute=59, second=59, tzinfo=tz)
2020-02-29 08:08:30 +00:00
class ProductViewSet(mixins.CreateModelMixin,
mixins.RetrieveModelMixin,
mixins.ListModelMixin,
GenericViewSet):
"""
A customer-facing viewset that provides default `create()`, `retrieve()`
and `list()`.
"""
pass