diff --git a/.gitignore b/.gitignore index 9903a07..cec5a83 100644 --- a/.gitignore +++ b/.gitignore @@ -64,3 +64,5 @@ venv.bak/ !.vscode/launch.json !.vscode/extensions.json .history +db.sqlite3 +*.sqlite3 diff --git a/db.sqlite3 b/db.sqlite3 new file mode 100644 index 0000000..d84e825 Binary files /dev/null and b/db.sqlite3 differ diff --git a/myapp/forms.py b/myapp/forms.py index 7756ad2..f7ab984 100644 --- a/myapp/forms.py +++ b/myapp/forms.py @@ -32,6 +32,7 @@ def must_be_unique_user(value): ('Other', 'Other') ] class IssueForm(forms.Form): + title = forms.CharField( widget = forms.TextInput( attrs={'class': 'form-control'} diff --git a/myapp/migrations/__init__.py b/myapp/migrations/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/myapp/templates/registration/login.html b/myapp/templates/registration/login.html index eb579e9..5a1199b 100644 --- a/myapp/templates/registration/login.html +++ b/myapp/templates/registration/login.html @@ -30,4 +30,25 @@

Log in

-{% endblock %} \ No newline at end of file +{% load socialaccount %} + + + Google Registration + + + +

My Google Login Project

+ {% if user.is_authenticated %} +

Welcome, {{ user.username }} !

+ + {% else %} +

My Google Login Project

+ Login with Google + {% endif %} + + + + + +{% endblock %} + diff --git a/myapp/views.py b/myapp/views.py index 9f9aa28..b7294f3 100644 --- a/myapp/views.py +++ b/myapp/views.py @@ -42,7 +42,7 @@ def submit(request): @login_required def viewissues(request): if request.method == "POST": - form = forms.IssueFilter(request.POST) + form = forms.IssueFilter(data=request.POST, request=request) if form.is_valid(): issues_list = models.Issue_Model.objects.all() if (form.cleaned_data['keyword']): @@ -57,7 +57,7 @@ def viewissues(request): Q(issue_type__exact=form.cleaned_data['issue_type']) ) else: - form = forms.IssueFilter() + form = forms.IssueFilter(request=request) issues_list = models.Issue_Model.objects.all() else: form = forms.IssueFilter() @@ -348,4 +348,3 @@ def edit_ticket(request, id): return render(request, "editticket.html", context=context) else: return redirect("/viewmysubmittedissues.html") - \ No newline at end of file diff --git a/mysite/settings.py b/mysite/settings.py index 4e4be1b..37daaab 100644 --- a/mysite/settings.py +++ b/mysite/settings.py @@ -10,6 +10,8 @@ https://docs.djangoproject.com/en/3.0/ref/settings/ """ +# https://www.youtube.com/watch?v=ZTBexYIIOP8 + import os # Build paths inside the project like this: os.path.join(BASE_DIR, ...) @@ -35,11 +37,17 @@ INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', - 'django.contrib.contenttypes', + 'django.contrib.contenttypes', + 'django.contrib.sites', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', - 'myapp'#, + 'myapp', + 'allauth', + 'allauth.account', + 'allauth.socialaccount', + 'allauth.socialaccount.providers.google', + #'crispy_forms' ] @@ -122,4 +130,27 @@ # https://docs.djangoproject.com/en/3.0/howto/static-files/ STATIC_URL = '/static/' -#CRISPY_TEMPLATE_PACK = 'bootstrap4' \ No newline at end of file + +# Django allauth settings +AUTHENTICATION_BACKENDS = ( + # Needed to login by username in Django admin, regardless of 'allauth' + 'django.contrib.auth.backends.ModelBackend', + + # 'allauth' specific authenication methods, such as login by email + 'allauth.account.auth_backends.AuthenticationBackend', +) + +SITE_ID = 1 + +SOCIALACCOUNT_PROVIDERS = { + 'google': { + 'SCOPE': [ + 'profile', + 'email', + ], + 'AUTH_PARAMS': { + 'access_type': 'online', + } + } +} +#CRISPY_TEMPLATE_PACK = 'bootstrap4' diff --git a/mysite/urls.py b/mysite/urls.py index 7ea0131..5922de5 100644 --- a/mysite/urls.py +++ b/mysite/urls.py @@ -13,12 +13,15 @@ 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ + from django.contrib import admin from django.urls import path, include +from django.views.generic import TemplateView import myapp urlpatterns = [ path('admin/', admin.site.urls), + path('accounts/', include('allauth.urls')), path('', include('myapp.urls') ), ]