Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Help a cause by building a donation system
Search
Dražen Lučanin
April 29, 2017
Programming
97
0
Share
Help a cause by building a donation system
DjangoGirls Vienna April 2017 lightning talk
Dražen Lučanin
April 29, 2017
More Decks by Dražen Lučanin
See All by Dražen Lučanin
Digitalisation for Citizen Empowerment
metakermit
0
53
Crowdfunding Python (& other IT) projects
metakermit
0
120
Pokreni posao: Freelancing
metakermit
1
230
Efficiently deploying Django
metakermit
1
190
Home office on a budget
metakermit
0
140
How to start freelancing
metakermit
0
250
From freelancing to incorporating
metakermit
0
240
Running a company as an e-Resident in Croatia
metakermit
0
710
CSS Animations
metakermit
0
370
Other Decks in Programming
See All in Programming
「効かない!」依存性注入(DI)を活用したAPI Platformのエラーハンドリング奮闘記
mkmk884
0
280
Coding at the Speed of Thought: The New Era of Symfony Docker
dunglas
0
3.9k
飯MCP
yusukebe
0
440
RSAが破られる前に知っておきたい 耐量子計算機暗号(PQC)入門 / Intro to PQC: Preparing for the Post-RSA Era
mackey0225
3
100
AIと共にエンジニアとPMの “二刀流”を実現する
naruogram
0
110
Nuxt Server Components
wattanx
0
230
Tamach-sre-3_ANDPAD-shimaison93
mane12yurks38
0
220
AWS×クラウドネイティブソフトウェア設計 / AWS x Cloud-Native Software Design
nrslib
16
3.5k
AI時代のシステム設計:ドメインモデルで変更しやすさを守る設計戦略
masuda220
PRO
6
1.1k
OTP を自動で入力する裏技
megabitsenmzq
0
130
モダンOBSプラグイン開発
umireon
0
190
RailsのValidatesをSwift Macrosで再現してみた
hokuron
0
140
Featured
See All Featured
Technical Leadership for Architectural Decision Making
baasie
3
300
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
170
WENDY [Excerpt]
tessaabrams
9
37k
How to train your dragon (web standard)
notwaldorf
97
6.6k
Art, The Web, and Tiny UX
lynnandtonic
304
21k
KATA
mclloyd
PRO
35
15k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
9.9k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
89
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
2
620
Facilitating Awesome Meetings
lara
57
6.8k
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Typedesign – Prime Four
hannesfritz
42
3k
Transcript
Help a cause by building a donation system Dražen Lučanin
@metakermit
• Helping a young green party run for local elections
in Zagreb • Inspiration for applying your Django skills :) Background
Functionality • Donation form with field validation • Talking to
an external API to generate a scannable 2D barcode • Email the payment information • Admin interface ◦ confirming payments ◦ exporting reports
Model class Donation(models.Model): uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) submitted_time =
models.DateTimeField(auto_now_add=True) OIB = models.CharField(max_length=11, validators=[oib_validator]) name = models.CharField(max_length=30, validators=[utf8_30_validator]) email = models.EmailField() street = models.CharField(max_length=27, validators=[utf8_27_validator]) place = models.CharField(max_length=27, validators=[utf8_27_validator]) phone = models.CharField(max_length=30, blank=True) # optional physical_person = models.BooleanField(default=True) amount = models.PositiveIntegerField() paid = models.BooleanField(default=False) barcode = models.ImageField(blank=True, upload_to='barcodes/%Y/%m/%d') invoice_image = models.ImageField(blank=True, upload_to='invoices/%Y/%m/%d')
None
Talking to an external API – requests hub3_args = {
"renderer": "image", "data": { "amount": self.amount, "sender": { "name": self.name, }, "receiver": { "iban": settings.DONATIONS_RECIPIENT_IBAN, } } } response = requests.post( 'https://hub3.bigfish.software/api/v1/barcode', json=hub3_args )
We even got a bit fancy using PIL… img =
Image.open(blank_invoice_path) draw = ImageDraw.Draw(img) draw.text((749, 132), settings.DONATIONS_RECIPIENT_IBAN, text_color, font=font)
Popular payment services • Stripe • BrainTree
Email the payment info – django-anymail + Mailgun msg =
EmailMultiAlternatives( subject="Uplatnica za donaciju", body=text_content, to=[f"{donation.name} <{donation.email}>"] ) msg.attach('uplatnica.jpg', invoice_file.getvalue(), 'image/jpeg') msg.attach('barcode.png', barcode_file.getvalue(), 'image/png') # Send it: msg.send()
And it works… • http://www.zagrebjenas.hr/doniraj/
Thanks! • Now go build your own project :)