blob: 3d01ad74571239e185fa249eed8b8ff251d78fb4 (
plain)
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
|
from django.views.generic import UpdateView, DetailView, ListView
from django.views.generic.edit import CreateView, DeleteView, UpdateView
from django.utils.decorators import method_decorator
from django.contrib.auth.decorators import login_required
from django.urls import reverse
from .models import Post
class PostListView(ListView):
model = Post
@method_decorator(login_required)
def dispatch(self, *args, **kwargs):
return super(PostListView, self).dispatch(*args, **kwargs)
def get_queryset(self):
return Post.objects.filter(user=self.request.user).order_by("-needs_update")
class PostNotesView(DetailView):
model = Post
@method_decorator(login_required)
def dispatch(self, *args, **kwargs):
return super(PostNotesView, self).dispatch(*args, **kwargs)
'''
class UpdateViewWithUser(UpdateView):
def get_form_kwargs(self, **kwargs):
kwargs = super().get_form_kwargs(**kwargs)
kwargs.update({'user': self.request.user})
return kwargs
class ProfileView(UpdateViewWithUser):
model = UserProfile
form_class = ProfileForm
template_name = "accounts/change-settings.html"
def get_object(self):
return self.request.user.profile
class SettingsListView(DetailView):
model = UserProfile
template_name = "accounts/profile.html"
def get_object(self):
return self.request.user.profile
'''
|