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
97
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
51
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
Ruby and LLM Ecosystem 2nd
koic
1
400
ふつうの Rubyist、ちいさなデバイス、大きな一年
bash0c7
0
790
Agentic AI: Evolution oder Revolution
mobilelarson
PRO
0
140
DSPy入門 Pythonで実現する自動プロンプト最適化 〜人手によるプロンプト調整からの卒業〜
seaturt1e
1
650
maplibre-gl-layers - 地図に移動体たくさん表示したい
kekyo
PRO
0
240
エラーログのマスキングの仕組みづくりに役立ったASTの話
kumoichi
0
160
PostgreSQL を使った快適な go test 環境を求めて
otakakot
0
530
API Platformを活用したPHPによる本格的なWeb API開発 / api-platform-book-intro
ttskch
1
130
20260228_JAWS_Beginner_Kansai
takuyay0ne
5
470
AIコードレビューの導入・運用と AI駆動開発における「AI4QA」の取り組みについて
hagevvashi
0
350
社内規程RAGの精度を73.3% → 100%に改善した話
oharu121
13
7.9k
Swift ConcurrencyでよりSwiftyに
yuukiw00w
0
250
Featured
See All Featured
Large-scale JavaScript Application Architecture
addyosmani
515
110k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
170
How to train your dragon (web standard)
notwaldorf
97
6.5k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
122
21k
Into the Great Unknown - MozCon
thekraken
40
2.3k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.7k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.1k
Scaling GitHub
holman
464
140k
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
89
HDC tutorial
michielstock
1
520
GraphQLの誤解/rethinking-graphql
sonatard
75
11k
How to build a perfect <img>
jonoalderson
1
5.2k
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 :)