Skip to content

Commit

Permalink
Bugfix Login, Logout, Register
Browse files Browse the repository at this point in the history
  • Loading branch information
betty-gures committed May 29, 2022
1 parent 136406e commit 724c506
Show file tree
Hide file tree
Showing 63 changed files with 461 additions and 130 deletions.
2 changes: 1 addition & 1 deletion myclub_website/TEMP/template_58888/intense-taxi/forms.html
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ <h1>Forms</h1>
<div class="offset-top-44">
<p>With forms you can get almost any kind of information from <br class="veil reveal-lg-inline-block"> your visitors, who will definitely appreciate this attractive element.</p>
</div>
<!-- Create an account-->
<!-- Create an accounts-->
<div class="offset-top-55">
<h5>Create an account</h5>
<div class="offset-top-30">
Expand Down
Empty file.
3 changes: 3 additions & 0 deletions myclub_website/accounts/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
6 changes: 6 additions & 0 deletions myclub_website/accounts/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class AccountsConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'accounts'
11 changes: 11 additions & 0 deletions myclub_website/accounts/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User
from django import forms


class SignUpForm(UserCreationForm):
class Meta:
model = User
fields = ('username', 'first_name',
'last_name', 'email',
'password1', 'password2',)
Empty file.
3 changes: 3 additions & 0 deletions myclub_website/accounts/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.db import models

# Create your models here.
3 changes: 3 additions & 0 deletions myclub_website/accounts/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
10 changes: 10 additions & 0 deletions myclub_website/accounts/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from django.urls import path
from django.contrib.auth import views

from accounts.views import SignUpView

urlpatterns = [
path('login/', views.LoginView.as_view(), name='login'),
path('logout/', views.LogoutView.as_view(), name='logout'),
path('signup/', SignUpView.as_view(), name='signup')
]
30 changes: 30 additions & 0 deletions myclub_website/accounts/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from django.contrib.auth.views import LoginView
from django.http import HttpResponseRedirect
from django.shortcuts import render
from django.urls import reverse
from django import views

from accounts.forms import SignUpForm


class SignUpView(views.View):

def get(self, request):
form = SignUpForm()
context = {
'form': form
}
return render(request, 'registration/signup.html', context)

def post(self, request):
form = SignUpForm(request.POST)
if form.is_valid():
form.save()
return HttpResponseRedirect(reverse('index'))
context = {
'form': form
}
return render(request, 'registration/signup.html', context)

# class CustomLoginView(LoginView):
# pass
4 changes: 3 additions & 1 deletion myclub_website/courses/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ class CategoryAdmin(admin.ModelAdmin):
admin.site.register(Category,CategoryAdmin)

class CoursesAdmin(admin.ModelAdmin):
list_display = ['title', 'status', 'category', 'create_at']
list_display = ['title', 'status',
'category',
'create_at']
list_filter = ['status']
ordering = ['category', 'title']
admin.site.register(Courses,CoursesAdmin)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.0.3 on 2022-05-29 08:47

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('courses', '0009_quiz_quizquestions'),
]

operations = [
migrations.AlterField(
model_name='quizquestions',
name='question',
field=models.TextField(blank=True),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 4.0.3 on 2022-05-29 11:35

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('courses', '0010_alter_quizquestions_question'),
]

operations = [
migrations.RemoveField(
model_name='courses',
name='category',
),
migrations.AddField(
model_name='courses',
name='category',
field=models.ManyToManyField(to='courses.category'),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 4.0.3 on 2022-05-29 11:36

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('courses', '0011_remove_courses_category_courses_category'),
]

operations = [
migrations.RemoveField(
model_name='courses',
name='category',
),
migrations.AddField(
model_name='courses',
name='category',
field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to='courses.category'),
preserve_default=False,
),
]
50 changes: 32 additions & 18 deletions myclub_website/home/templates/content_categories.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,41 @@

<section class="section novi-background section-98 section-md-110">
<div class="container">
<h1>Categories </h1>
<hr class="divider bg-mantis">
<div class="row justify-content-md-center offset-top-66 text-left">
<h1>Categories </h1>
<hr class="divider bg-mantis">
<div class="row justify-content-md-center offset-top-66 text-left">
<div class="col-md-12 col-lg-6">
<ul>
{% for rs in categoriesdata %}
<ul>
{% for category in categoriesdata %}
{% if not category.parent %}
<li><a href="/category_detail/{{category.id}}">{{category.title}}</a></li>
<ul>
{% for sub_category in categoriesdata %}
{% if sub_category.parent and sub_category.parent.id == category.id %}
<li><a href="/category_detail/{{sub_category.id}}">{{sub_category.title}}</a></li>
{% endif %}
{% endfor %}
</ul>
{% endif %}
{% endfor %}
</ul>
</div>
</div>
</section>
<!-- <ul>-->
<!-- {% for rs in categoriesdata %}-->

{% for sub_category in parents %}
{% if sub_category.parent.id == rs.id %}
<li class="post-meta inset-left-20">
<span class="novi-icon icon icon-xxs text-middle mdi mdi-file-document"></span>
<a href="/category_detail/{{sub_category.id}}">{{sub_category.title}}</a> (<a href="/category_detail/{{rs.id}}">{{rs.title}}</a>)
</li>
<!-- {% for sub_category in parents %}-->
<!-- {% if sub_category.parent.id == rs.id %}-->
<!-- <li class="post-meta inset-left-20">-->
<!-- <span class="novi-icon icon icon-xxs text-middle mdi mdi-file-document"></span>-->
<!-- <a href="/category_detail/{{sub_category.id}}">{{sub_category.title}}</a> (<a href="/category_detail/{{rs.id}}">{{rs.title}}</a>)-->
<!-- </li>-->

{% endif %}
{% endfor %}
<!-- {% endif %}-->
<!-- {% endfor %}-->


{% endfor %}
</ul>
</div>
</div>
</section>
<!-- {% endfor %}-->
<!-- </ul>-->

16 changes: 5 additions & 11 deletions myclub_website/home/templates/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,14 @@
</div>
<!-- RD Navbar Nav-->
<ul class="rd-navbar-nav">
<li {% if page==
'home_page'%}class="active"{% endif %}><a href="/"><span>Home</span></a></li>
<li {% if page==
'aboutus'%}class="active"{% endif %}><a class="new"
href="/aboutus"><span>ABOUT</span></a></li>
<li {% if page==
'categories'%}class="active"{% endif %}><a class="new" href="/categories"><span>CATEGORIES</span></a></li>
<li {% if page==
'home'%} class="active"{% endif %}><a class="new" href="/courses"><span>LEARNING ENVIRONMENTS</span></a></li>
<li {% if page == 'home_page' %} class= "active" {% endif %}> <a href="/"><span>Home</span></a></li>
<li {% if page == 'aboutus' %} class= "active" {% endif %}> <a class="new"href="/aboutus"><span>ABOUT</span></a></li>
<li {% if page == 'categories' %} class= "active" {% endif %}> <a class="new" href="/categories"><span>CATEGORIES</span></a></li>
<li {% if page == 'home' %} class= "active" {% endif %}> <a class="new" href="/courses"><span>LEARNING ENVIRONMENTS</span></a></li>

<li>
{% if not user.is_authenticated %}
<a class="new" href="/login"><span>LOGIN</span></a> | <a class="new"
href="sign-in.html"><span>SIGN UP</span></a>
<a class="new" href="/accounts/login"><span>LOGIN | SIGN UP </span></a>
</li>
{% else %}
<a class="new" href="/profile/"><span>{{user.first_name}}</span></a>
Expand Down
3 changes: 1 addition & 2 deletions myclub_website/home/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ def course_search(request):

def categories(request):
categoriesdata = Category.objects.all().order_by('title')[:1000]
category_parents = Category.objects.all()
context = {'categoriesdata': categoriesdata, 'page': 'categories', 'parents': category_parents}
context = {'categoriesdata': categoriesdata, 'page': 'categories',}
return render(request, 'categories.html', context)


Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 14 additions & 15 deletions myclub_website/myclub_website/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,24 @@
ALLOWED_HOSTS = ['*', '127.0.0.1', 'localhost']

LOGOUT_REDIRECT_URL = "/"

LOGIN_REDIRECT_URL = "/"
# Application definition

AUTHENTICATION_BACKENDS = [

# Needed to login by username in Django admin, regardless of `allauth`
'django.contrib.auth.backends.ModelBackend',

# `allauth` specific authentication methods, such as login by e-mail
'allauth.account.auth_backends.AuthenticationBackend',

]
# AUTHENTICATION_BACKENDS = [
#
# # Needed to login by username in Django admin, regardless of `allauth`
# 'django.contrib.auth.backends.ModelBackend',
#
# # `allauth` specific authentication methods, such as login by e-mail
# 'allauth.accounts.auth_backends.AuthenticationBackend',
#
# ]

INSTALLED_APPS = [
'courses.apps.CoursesConfig',
'events',
'social',
'accounts',
'landing',
'colearning',
'home.apps.HomeConfig',
Expand All @@ -50,9 +51,9 @@
'django.contrib.staticfiles',
'django.contrib.sites',

'allauth',
'allauth.account',
'allauth.socialaccount',
# 'allauth',
# 'allauth.accounts',
# 'allauth.socialaccount',

'ckeditor',
'ckeditor_uploader',
Expand Down Expand Up @@ -177,8 +178,6 @@

CRISPY_TEMPLATE_PACK = 'bootstrap4'

LOGIN_REDIRECT_URL = 'post-list'

ACCOUNT_EMAIL_REQUIRED = True

EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
Expand Down
2 changes: 1 addition & 1 deletion myclub_website/myclub_website/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
path('',views.home_page, name='home_page'),
path('landing/',include('landing.urls')),
# path('accounts/', include('allauth.urls')),
path('accounts/', include('django.contrib.auth.urls')),
path('accounts/', include('accounts.urls')),
path('social/', include('social.urls'), name='social'),
path('courses/', include('home.urls')),
path('ckeditor/', include('ckeditor_uploader.urls')),
Expand Down
Loading

0 comments on commit 724c506

Please sign in to comment.