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
0
92
Help a cause by building a donation system
DjangoGirls Vienna April 2017 lightning talk
Dražen Lučanin
April 29, 2017
Tweet
Share
More Decks by Dražen Lučanin
See All by Dražen Lučanin
Digitalisation for Citizen Empowerment
metakermit
0
43
Crowdfunding Python (& other IT) projects
metakermit
0
98
Pokreni posao: Freelancing
metakermit
1
210
Efficiently deploying Django
metakermit
1
180
Home office on a budget
metakermit
0
130
How to start freelancing
metakermit
0
240
From freelancing to incorporating
metakermit
0
240
Running a company as an e-Resident in Croatia
metakermit
0
700
CSS Animations
metakermit
0
350
Other Decks in Programming
See All in Programming
ASP.NETアプリケーションのモダナイズ インフラ編
tomokusaba
1
410
童醫院敏捷轉型的實踐經驗
cclai999
0
190
Gleamという選択肢
comamoca
6
760
エンジニア向け採用ピッチ資料
inusan
0
160
今ならAmazon ECSのサービス間通信をどう選ぶか / Selection of ECS Interservice Communication 2025
tkikuc
20
3.6k
PostgreSQLのRow Level SecurityをPHPのORMで扱う Eloquent vs Doctrine #phpcon #track2
77web
2
350
Composerが「依存解決」のためにどんな工夫をしているか #phpcon
o0h
PRO
1
230
datadog dash 2025 LLM observability for reliability and stability
ivry_presentationmaterials
0
110
Deep Dive into ~/.claude/projects
hiragram
8
1.5k
なんとなくわかった気になるブロックテーマ入門/contents.nagoya 2025 6.28
chiilog
1
220
「Cursor/Devin全社導入の理想と現実」のその後
saitoryc
0
160
LINEヤフー データグループ紹介
lycorp_recruit_jp
0
890
Featured
See All Featured
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
26k
What's in a price? How to price your products and services
michaelherold
246
12k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
138
34k
The Power of CSS Pseudo Elements
geoffreycrofte
77
5.8k
Site-Speed That Sticks
csswizardry
10
660
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
34
3k
4 Signs Your Business is Dying
shpigford
184
22k
How GitHub (no longer) Works
holman
314
140k
The Straight Up "How To Draw Better" Workshop
denniskardys
234
140k
Art, The Web, and Tiny UX
lynnandtonic
299
21k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
50k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
48
2.8k
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 :)