Révision cc12ccfe
Ajouté par Serghei Mihai (congés, retour 15/05) il y a plus de 9 ans
corbo/views.py | ||
---|---|---|
7 | 7 |
from django.contrib.syndication.views import Feed |
8 | 8 |
from django.utils.feedgenerator import Atom1Feed |
9 | 9 |
|
10 |
|
|
11 | 10 |
import models |
11 |
from .forms import AnnounceForm, CategoryForm |
|
12 | 12 |
|
13 | 13 |
class HomepageView(ListView): |
14 | 14 |
model = models.Announce |
15 |
template_name = 'homepage.html' |
|
15 |
template_name = 'corbo/homepage.html'
|
|
16 | 16 |
|
17 | 17 |
homepage = HomepageView.as_view() |
18 | 18 |
|
19 | 19 |
class AnnounceCreateView(CreateView): |
20 |
model = models.Announce |
|
20 |
form_class = AnnounceForm |
|
21 |
template_name = 'corbo/announce_form.html' |
|
22 |
success_url = '..' |
|
21 | 23 |
|
22 | 24 |
add_announce = AnnounceCreateView.as_view() |
23 | 25 |
|
24 | 26 |
class AnnounceEditView(UpdateView): |
25 | 27 |
model = models.Announce |
28 |
success_url = '../..' |
|
26 | 29 |
|
27 | 30 |
edit_announce = AnnounceEditView.as_view() |
28 | 31 |
|
29 | 32 |
class AnnounceDeleteView(DeleteView): |
33 |
success_url = '../..' |
|
30 | 34 |
model = models.Announce |
31 | 35 |
|
32 | 36 |
delete_announce = AnnounceDeleteView.as_view() |
33 | 37 |
|
34 |
edit_announce = AnnounceEditView.as_view() |
|
35 |
|
|
36 | 38 |
class CategoryCreateView(CreateView): |
37 |
model = models.Category |
|
39 |
form_class = CategoryForm |
|
40 |
template_name = 'corbo/category_form.html' |
|
41 |
success_url = '..' |
|
42 |
|
|
43 |
def form_valid(self, form): |
|
44 |
form.save() |
|
45 |
return super(CategoryCreateView, self).form_valid(form) |
|
38 | 46 |
|
39 | 47 |
add_category = CategoryCreateView.as_view() |
40 | 48 |
|
41 | 49 |
class CategoryEditView(UpdateView): |
42 | 50 |
model = models.Category |
51 |
success_url = '..' |
|
43 | 52 |
|
44 | 53 |
edit_category = CategoryEditView.as_view() |
45 | 54 |
|
... | ... | |
51 | 60 |
|
52 | 61 |
class ManageView(ListView, MultipleObjectMixin): |
53 | 62 |
paginate_by = settings.ANNOUNCES_PER_PAGE |
54 |
template_name = 'manage.html' |
|
63 |
template_name = 'corbo/manage.html'
|
|
55 | 64 |
model = models.Announce |
56 | 65 |
|
57 | 66 |
def get_queryset(self): |
Formats disponibles : Unified diff
gadjo theme used for templates
Category and announces management views and urls updated