$30 off During Our Annual Pro Sale. View Details »
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
95
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
47
Crowdfunding Python (& other IT) projects
metakermit
0
110
Pokreni posao: Freelancing
metakermit
1
220
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
360
Other Decks in Programming
See All in Programming
開発に寄りそう自動テストの実現
goyoki
2
950
DSPy Meetup Tokyo #1 - はじめてのDSPy
masahiro_nishimi
1
170
まだ間に合う!Claude Code元年をふりかえる
nogu66
5
820
テストやOSS開発に役立つSetup PHP Action
matsuo_atsushi
0
150
LLM Çağında Backend Olmak: 10 Milyon Prompt'u Milisaniyede Sorgulamak
selcukusta
0
120
【Streamlit x Snowflake】データ基盤からアプリ開発・AI活用まで、すべてをSnowflake内で実現
ayumu_yamaguchi
1
120
251126 TestState APIってなんだっけ?Step Functionsテストどう変わる?
east_takumi
0
320
AIの誤りが許されない業務システムにおいて“信頼されるAI” を目指す / building-trusted-ai-systems
yuya4
6
3.4k
20251127_ぼっちのための懇親会対策会議
kokamoto01_metaps
2
430
宅宅自以為的浪漫:跟 AI 一起為自己辦的研討會寫一個售票系統
eddie
0
500
リリース時」テストから「デイリー実行」へ!開発マネージャが取り組んだ、レガシー自動テストのモダン化戦略
goataka
0
130
How Software Deployment tools have changed in the past 20 years
geshan
0
29k
Featured
See All Featured
Art, The Web, and Tiny UX
lynnandtonic
303
21k
Reflections from 52 weeks, 52 projects
jeffersonlam
355
21k
jQuery: Nuts, Bolts and Bling
dougneiner
65
8.2k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
359
30k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
132
19k
YesSQL, Process and Tooling at Scale
rocio
174
15k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.3k
Scaling GitHub
holman
464
140k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
9.8k
Designing for humans not robots
tammielis
254
26k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
9
1k
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 :)