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
80
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
33
Crowdfunding Python (& other IT) projects
metakermit
0
84
Pokreni posao: Freelancing
metakermit
1
200
Efficiently deploying Django
metakermit
1
150
Home office on a budget
metakermit
0
110
How to start freelancing
metakermit
0
220
From freelancing to incorporating
metakermit
0
210
Running a company as an e-Resident in Croatia
metakermit
0
680
CSS Animations
metakermit
0
320
Other Decks in Programming
See All in Programming
コンテナをたくさん詰め込んだシステムとランタイムの変化
makihiro
1
150
Stackless и stackful? Корутины и асинхронность в Go
lamodatech
0
960
menu基盤チームによるGoogle Cloudの活用事例~Application Integration, Cloud Tasks編~
yoshifumi_ishikura
0
110
創造的活動から切り拓く新たなキャリア 好きから始めてみる夜勤オペレーターからSREへの転身
yjszk
1
140
Асинхронность неизбежна: как мы проектировали сервис уведомлений
lamodatech
0
980
iOS開発におけるCopilot For XcodeとCode Completion / copilot for xcode
fuyan777
1
110
rails stats で紐解く ANDPAD のイマを支える技術たち
andpad
1
300
선언형 UI에서의 상태관리
l2hyunwoo
0
190
CloudflareStack でRAGに入門
asahiiwm
0
100
各クラウドサービスにおける.NETの対応と見解
ymd65536
0
180
良いユニットテストを書こう
mototakatsu
8
3.1k
[JAWS-UG横浜 #76] イケてるアップデートを宇宙いち早く紹介するよ!
maroon1st
0
510
Featured
See All Featured
Building a Scalable Design System with Sketch
lauravandoore
460
33k
The Pragmatic Product Professional
lauravandoore
32
6.3k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
170
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
GitHub's CSS Performance
jonrohan
1031
460k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.9k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
3
170
Building an army of robots
kneath
302
44k
Java REST API Framework Comparison - PWX 2021
mraible
28
8.3k
Embracing the Ebb and Flow
colly
84
4.5k
A designer walks into a library…
pauljervisheath
205
24k
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 :)