Fix login/logout/submit
This commit is contained in:
parent
fa0c4c1051
commit
8925e939a7
3 changed files with 17 additions and 29 deletions
|
@ -7,7 +7,7 @@
|
|||
<form method="post">
|
||||
{% csrf_token %}
|
||||
{{ form|crispy }}
|
||||
<input type="submit" value="Submit URL">
|
||||
<input type="submit" value="Submit">
|
||||
</form>
|
||||
</div>
|
||||
|
|
@ -20,8 +20,8 @@ from ipv6ula import views
|
|||
|
||||
urlpatterns = [
|
||||
path('', views.IndexView.as_view(), name='index'),
|
||||
# path('submit/', views.SubmitView.as_view(), name='submit'),
|
||||
# path('login/', views.LoginView.as_view(), name='login'),
|
||||
# path('logout/', views.logout_view, name='logout'),
|
||||
path('submit/', views.SubmitView.as_view(), name='submit'),
|
||||
path('login/', views.LoginView.as_view(), name='login'),
|
||||
path('logout/', views.logout_view, name='logout'),
|
||||
path('admin/', admin.site.urls),
|
||||
]
|
||||
|
|
|
@ -15,31 +15,19 @@ class IndexView(ListView):
|
|||
paginate_by = 50
|
||||
queryset = ULA.objects.order_by('prefix')
|
||||
|
||||
# class SubmitView(LoginRequiredMixin, CreateView):
|
||||
# model = BookmarkModel
|
||||
# fields = [ 'comment', 'url' ]
|
||||
# login_url = '/login/'
|
||||
# success_url = '/'
|
||||
class SubmitView(LoginRequiredMixin, CreateView):
|
||||
model = ULA
|
||||
fields = [ 'prefix', 'name', 'organization', 'website' ]
|
||||
login_url = '/login/'
|
||||
success_url = '/'
|
||||
|
||||
# def get_context_data(self, **kwargs):
|
||||
# context = super(CreateView, self).get_context_data(**kwargs)
|
||||
# context['site_name'] = settings.SITE_NAME
|
||||
# context['site_description'] = settings.SITE_DESCRIPTION
|
||||
def form_valid(self, form):
|
||||
form.instance.owner = self.request.user
|
||||
return super(SubmitView, self).form_valid(form)
|
||||
|
||||
# return context
|
||||
class LoginView(auth_views.LoginView):
|
||||
template_name = 'ipv6ula/login.html'
|
||||
|
||||
# def form_valid(self, form):
|
||||
# form.instance.owner = self.request.user
|
||||
# return super(SubmitView, self).form_valid(form)
|
||||
|
||||
# class LoginView(auth_views.LoginView):
|
||||
# template_name = 'ipv6ula/login.html'
|
||||
# extra_context = {}
|
||||
|
||||
# extra_context['site_name'] = settings.SITE_NAME
|
||||
# extra_context['site_description'] = settings.SITE_DESCRIPTION
|
||||
|
||||
|
||||
# def logout_view(request):
|
||||
# logout(request)
|
||||
# return redirect("/")
|
||||
def logout_view(request):
|
||||
logout(request)
|
||||
return redirect("/")
|
||||
|
|
Loading…
Add table
Reference in a new issue