Merge pull request 'RANDOMSEC-19' (#2) from RANDOMSEC-19 into master

Reviewed-on: #2
This commit is contained in:
Michał Najborowski 2022-01-25 16:47:24 +01:00
commit bc109087ba
13 changed files with 97 additions and 32 deletions

View File

@ -1,4 +1,5 @@
# MultiUserOpenRefine # MultiUserOpenRefine
![MultiUserOpenRefine](logo.svg) ![MultiUserOpenRefine](logo.svg)
MultiUserOpenRefine is an extension to open-source tool that, in addition to MultiUserOpenRefine is an extension to open-source tool that, in addition to

View File

@ -9,13 +9,12 @@ https://docs.djangoproject.com/en/4.0/topics/settings/
For the full list of settings and their values, see For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.0/ref/settings/ https://docs.djangoproject.com/en/4.0/ref/settings/
""" """
from pathlib import Path
import os import os
from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'. # Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent BASE_DIR = Path(__file__).resolve().parent.parent
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
# Quick-start development settings - unsuitable for production # Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/ # See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/
@ -26,7 +25,7 @@ SECRET_KEY = 'django-insecure-t52#vo-k9ty*$@u9bf75hrkd#^o_)gadrz9$7w%xnkb-0#y!bi
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True DEBUG = True
ALLOWED_HOSTS = ["localhost", "127.0.0.1"] ALLOWED_HOSTS = []
# Application definition # Application definition
@ -38,7 +37,6 @@ INSTALLED_APPS = [
'django.contrib.sessions', 'django.contrib.sessions',
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'OpenRefineAuth.apps.OpenrefineauthConfig'
] ]
MIDDLEWARE = [ MIDDLEWARE = [
@ -118,15 +116,17 @@ USE_TZ = True
# Static files (CSS, JavaScript, Images) # Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.0/howto/static-files/ # https://docs.djangoproject.com/en/4.0/howto/static-files/
STATIC_URL = '/static/' STATIC_URL = 'static/'
STATICFILES_DIRS = ( STATICFILES_DIRS = (
os.path.join(BASE_DIR, "static"), os.path.join(BASE_DIR, 'static'),
) )
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
LOGIN_REDIRECT_URL = 'home'
LOGOUT_REDIRECT_URL = 'home'
# Default primary key field type # Default primary key field type
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field # https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
LOGIN_REDIRECT_URL = '/'

View File

@ -14,14 +14,16 @@ Including another URLconf
2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
""" """
from django.contrib import admin from django.contrib import admin
from django.contrib.staticfiles.storage import staticfiles_storage
from django.urls import path, include from django.urls import path, include
from OpenRefineAuth import views from django.views.generic import TemplateView, RedirectView
from django.views.generic.base import TemplateView
from django.contrib.staticfiles.urls import staticfiles_urlpatterns from .views import SignUpView
urlpatterns = [ urlpatterns = [
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
path('accounts/', include('django.contrib.auth.urls')), path('', include('django.contrib.auth.urls')),
path('signup/', SignUpView.as_view(), name='signup'),
path('', TemplateView.as_view(template_name='home.html'), name='home'), path('', TemplateView.as_view(template_name='home.html'), name='home'),
path('favicon.ico', RedirectView.as_view(url=staticfiles_storage.url('images/favicon.ico'))),
] ]
urlpatterns += staticfiles_urlpatterns()

View File

@ -0,0 +1,16 @@
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User
from django.urls import reverse_lazy
from django.views import generic
class SignUpForm(UserCreationForm):
class Meta:
model = User
fields = ('username', 'email',)
class SignUpView(generic.CreateView):
form_class = SignUpForm
success_url = reverse_lazy('login')
template_name = 'registration/signup.html'

Binary file not shown.

View File

@ -0,0 +1,3 @@
body {
background-color: #818fb7;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -2,8 +2,12 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
{% load static %}
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
<link rel="stylesheet" href="{% static 'base.css'%}">
<meta charset="utf-8"> <meta charset="utf-8">
<title>{% block title %}Django baseic login{% endblock %}</title> <title>{% block title %}Auth{% endblock %}</title>
</head> </head>
<body> <body>
<main> <main>

View File

@ -6,8 +6,10 @@
{% block content %} {% block content %}
{% if user.is_authenticated %} {% if user.is_authenticated %}
Hi {{ user.username }}! Hi {{ user.username }}!
<p><a href="{% url 'logout' %}">Log Out</a></p>
{% else %} {% else %}
<p>You are not logged in</p> <p>You are not logged in</p>
<a href="{% url 'login' %}">Log In</a> <p><a href="{% url 'login' %}">Log In</a></p>
<p><a href="{% url 'signup' %}">Sign Up</a></p>
{% endif %} {% endif %}
{% endblock %} {% endblock %}

View File

@ -5,9 +5,7 @@
{% block content %} {% block content %}
<h2>Log In</h2> <h2>Log In</h2>
{% load static %} <form method="post">
<img width="20%" height="20%" src="{% static "images/logo.jpg" %}" alt="logo"/>
{% csrf_token %} {% csrf_token %}
{{ form.as_p }} {{ form.as_p }}
<button type="submit">Log In</button> <button type="submit">Log In</button>

View File

@ -0,0 +1,13 @@
<!-- templates/registration/signup.html -->
{% extends 'base.html' %}
{% block title %}Sign Up{% endblock %}
{% block content %}
<h2>Sign Up</h2>
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Sign Up</button>
</form>
{% endblock %}

BIN
logo.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 KiB

26
logo.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 153 KiB