GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

ReservationsOrderReceived   A
last analyzed

Complexity

Total Complexity 0

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 13
rs 10
wmc 0
1
import datetime
2
3
from django.utils.translation import ugettext
4
5
from shoop.core.models import OrderLineType
6
from shoop.notify import Event, Variable
7
from shoop.notify.typology import Email, Language, Model, Phone, Text, Decimal, Integer, URL
8
from shoop.utils.dates import parse_date
9
10
11
class ReservationsOrderReceived(Event):
12
    identifier = "reservations_order_received"
13
14
    order = Variable("Order", type=Model("shoop.Order"))
15
    order_id = Variable("Order ID", type=Integer)
16
    order_details = Variable("Order Details", type=Text)
17
    order_url = Variable("Order URL", type=URL)
18
    customer_email = Variable("Customer Email", type=Email)
19
    customer_phone = Variable("Customer Phone", type=Phone)
20
    customer_name = Variable("Customer Name", type=Text)
21
    language = Variable("Language", type=Language)
22
    additional_notes = Variable("Additional Notes", type=Text)
23
    total_sum = Variable("Total Sum", type=Decimal)
24
25
26
def get_order_details(order):
27
    details = []
28
    for line in order.lines.filter(type=OrderLineType.PRODUCT):
29
        details.append("%s" % line.text)
30
        if line.product.type.identifier == "reservable":
31
            start = parse_date(line.extra_data["reservation_start"])
32
            end = start + datetime.timedelta(days=int(line.quantity))
33
            details.append(ugettext("    {nights} nights, {persons} persons, {start} - {end}".format(
34
                nights=int(line.quantity), persons=line.extra_data["persons"], start=start, end=end)
35
            ))
36
    return "\n".join(details)
37