-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNEW_PAGE_HOWTO.txt
55 lines (41 loc) · 2.2 KB
/
NEW_PAGE_HOWTO.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
A new page is required to "languagecards" – let's call it "Votes".
The vite.config.js and languagecards/urls.py needs a new row:
'languagecards/components/votes.jsx',
path('vote', VoteView.as_view()), # Also into the imports above: VoteView
This leads us to
components, where we need a votes.jsx (e.g let's copy languagecards.jsx),
and into
views, where a new view is to be set up:
class VoteView(ReactMixin, TemplateView):
template_name = 'languagecards/react.html'
app_root = 'languagecards/components/votes.jsx'
def get_props_data(self):
votes = Vote.objects.order_by('position', 'created_at')
serializer = VoteSerializer(votes, many=True)
return serializer.data
We need a VoteSerializer of course (and above into the imports: Vote).
Maybe a new link to frontend (to languagecards.jsx-be):
the key should not match to the previous ones!
Maybe admin.py or even models.py can need some new rows (in this case also a migration is needed).
/static/css/votes.css can have new CSS definitions
===============
A languagecards-ba új oldalt szeretnénk felvenni, mondjuk legyen a címe "Szavazatok".
vite.config.js és languagecards/urls.py igényli az új sort:
'languagecards/components/szavazatok.jsx',
path('szavazatok', VoteView.as_view()), # Fönt is felveendő az importok közé: VoteView
ez már át is vezet a
komponensek közé, ahol kell a szavazatok.jsx (pl. az languagecards.jsx másolataként),
valamint a
view-k közé, ahol is új view veendő fel:
class VoteView(ReactMixin, TemplateView):
template_name = 'languagecards/react.html'
app_root = 'languagecards/components/szavazatok.jsx'
def get_props_data(self):
votes = Vote.objects.order_by('position', 'created_at')
serializer = VoteSerializer(votes, many=True)
return serializer.data
Persze ehhez VoteSerializer is kell (meg ott fönt az importba Vote).
Vélhetően kell új link a frontendre (languagecards.jsx-be): a key ne egyezzen meg korábbi másikkal!
Arról most nincs szó, hogy az admin.py-ba kell-e új rész,
vagy esetleg a models.py-ba (és akkor migrációs fájl is kell).
A /static/css/languagecards.css-be kell tenni az esetleges CSS definíciókat.