-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpipelines.py
60 lines (43 loc) · 1.7 KB
/
pipelines.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# coding: utf-8
from flask import request
from quokka.modules.cart.pipelines.base import CartPipeline
from quokka.utils import get_current_user
from .models import Donation
class SetDonor(CartPipeline):
def process(self):
user = get_current_user()
donations = Donation.objects.filter(
cart=self.cart
)
for donation in donations:
donation.donor = user
donation.save()
if user.name and len(user.name.split()) > 1:
self.cart.sender_data = {
"name": user.name,
"email": user.email,
}
self.cart.belongs_to = user
self.cart.addlog("SetDonor Pipeline: defined sender data")
return self.go()
class CompleteInformation(CartPipeline):
def process(self):
user = get_current_user()
confirm = request.form.get("fundraising_complete_information_confirm")
if not confirm:
return self.render('fundraising/complete_information.html',
name=user.name)
display_name = request.form.get('display_name') or user.name
published = request.form.get('published', True)
donation_to_project = request.form.get('donation_to_project')
donations = Donation.objects.filter(
cart=self.cart
)
for donation in donations:
donation.published = self.cart.published = (published == u'on')
donation.display_name = display_name
donation.save()
if donation_to_project:
donation.set_project_campaign(donation_to_project, cart=self.cart)
self.cart.addlog("CompleteInformation Pipeline")
return self.go()