WeightsMixin   A
last analyzed

Complexity

Total Complexity 0

Size/Duplication

Total Lines 3
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 0
c 1
b 0
f 0
dl 0
loc 3
rs 10
1
# coding: utf-8
2
from __future__ import unicode_literals
3
4
import logging
5
6
import arrow
7
from django.conf import settings
8
from django.views.generic import CreateView, UpdateView, DeleteView
9
# dj_diabetes
10
from dj_diabetes.models import SuccessMixin, PaginateMixin
11
from dj_diabetes.views import LoginRequiredMixin
12
from dj_diabetes.models.weights import Weights
13
from dj_diabetes.forms.base import UserInstanceMixin
14
from dj_diabetes.forms.weights import WeightsForm
15
16
17
# Get an instance of a logger
18
logger = logging.getLogger(__name__)
19
20
21
class WeightsMixin(SuccessMixin):
22
    form_class = WeightsForm
23
    model = Weights
24
25
26
class WeightsCreateView(WeightsMixin, LoginRequiredMixin, UserInstanceMixin,
27
                        PaginateMixin, CreateView):
28
    """
29
        to Create Weights
30
    """
31
    template_name = "dj_diabetes/weights_form.html"
32
33
    def get_initial(self):
34
        return {'date_weights': arrow.utcnow().to(
35
            settings.TIME_ZONE).format('YYYY-MM-DD')}
36
37
38
class WeightsUpdateView(WeightsMixin, LoginRequiredMixin,
39
                        PaginateMixin, UpdateView):
40
    """
41
        to Edit Weights
42
    """
43
    template_name = "dj_diabetes/weights_form.html"
44
45
46
class WeightsDeleteView(WeightsMixin, DeleteView):
47
    """
48
        to Delete Weights
49
    """
50
    template_name = 'dj_diabetes/confirm_delete.html'
51