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.
Completed
Push — master ( 1ae418...21cf17 )
by Jason
01:27
created

send_order_received_notification()   A

Complexity

Conditions 2

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 2
dl 0
loc 11
rs 9.4285
1
import datetime
2
3
from django.dispatch import receiver
4
from django.utils.translation import ugettext
5
6
from shoop.core.models import OrderLineType
7
from shoop.front.signals import order_creator_finished
8
from shoop.notify import Event, Variable
9
from shoop.notify.typology import Email, Language, Model, Phone, Text, Decimal
10
from shoop.utils.dates import parse_date
11
12
13
class ReservationsOrderReceived(Event):
14
    identifier = "reservations_order_received"
15
16
    order = Variable("Order", type=Model("shoop.Order"))
17
    order_details = Variable("Order Details", type=Text)
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("    %s nights, %s persons, %s - %s" % (
34
                int(line.quantity), line.extra_data["persons"], start, end
35
            )))
36
    return "\n".join(details)
37
38
39
@receiver(order_creator_finished)
40
def send_order_received_notification(order, **kwargs):
41
    ReservationsOrderReceived(
42
        order=order,
43
        order_details=get_order_details(order),
44
        customer_email=order.email,
45
        customer_phone=order.phone,
46
        customer_name=order.billing_address.name if order.billing_address else "",
47
        language=order.language,
48
        additional_notes=order.customer_comment,
49
        total_sum=order.taxful_total_price_value,
50
    ).run()
0 ignored issues
show
Bug introduced by
The Instance of ReservationsOrderReceived does not seem to have a member named run.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
51