Adds blocked users view
also refactors the setting view
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
''' views for actions you can take in the application '''
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.shortcuts import get_object_or_404, redirect
|
||||
from django.template.response import TemplateResponse
|
||||
from django.utils.decorators import method_decorator
|
||||
from django.views import View
|
||||
|
||||
@ -13,6 +14,8 @@ class Block(View):
|
||||
''' blocking users '''
|
||||
def get(self, request):
|
||||
''' list of blocked users? '''
|
||||
return TemplateResponse(
|
||||
request, 'blocks.html', {'title': 'Blocked Users'})
|
||||
|
||||
def post(self, request, user_id):
|
||||
''' block a user '''
|
||||
@ -26,4 +29,4 @@ class Block(View):
|
||||
privacy='direct',
|
||||
direct_recipients=[to_block]
|
||||
)
|
||||
return redirect('/blocks')
|
||||
return redirect('/block')
|
||||
|
@ -88,6 +88,14 @@ class PasswordReset(View):
|
||||
@method_decorator(login_required, name='dispatch')
|
||||
class ChangePassword(View):
|
||||
''' change password as logged in user '''
|
||||
def get(self, request):
|
||||
''' change password page '''
|
||||
data = {
|
||||
'title': 'Change Password',
|
||||
'user': request.user,
|
||||
}
|
||||
return TemplateResponse(request, 'change_password.html', data)
|
||||
|
||||
def post(self, request):
|
||||
''' allow a user to change their password '''
|
||||
new_password = request.POST.get('password')
|
||||
|
@ -147,14 +147,11 @@ class Following(View):
|
||||
class EditUser(View):
|
||||
''' edit user view '''
|
||||
def get(self, request):
|
||||
''' profile page for a user '''
|
||||
user = request.user
|
||||
|
||||
form = forms.EditUserForm(instance=request.user)
|
||||
''' edit profile page for a user '''
|
||||
data = {
|
||||
'title': 'Edit profile',
|
||||
'form': form,
|
||||
'user': user,
|
||||
'form': forms.EditUserForm(instance=request.user),
|
||||
'user': request.user,
|
||||
}
|
||||
return TemplateResponse(request, 'edit_user.html', data)
|
||||
|
||||
|
Reference in New Issue
Block a user