diff --git a/django_apps/settings.py b/django_apps/settings.py index d9a443df4c3d377146060179e252fd04d8c30b65..1bbaa653a0325ba44b9c9c6f24abf1fe52abb09d 100644 --- a/django_apps/settings.py +++ b/django_apps/settings.py @@ -29,9 +29,11 @@ ALLOWED_HOSTS = [] # Application definition + #'polls.apps.PollsConfig', INSTALLED_APPS = [ - 'polls.apps.PollsConfig', + 'sifrovacka.apps.SifrovackaConfig', + 'django_registration', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', diff --git a/django_apps/urls.py b/django_apps/urls.py index 95cd9a7baab40a9523d7627076fc6b67aaf9c52b..d3c3f95b70ce0af72b597b482f4b954fee07497e 100644 --- a/django_apps/urls.py +++ b/django_apps/urls.py @@ -17,7 +17,7 @@ from django.contrib import admin from django.urls import path, include urlpatterns = [ - path('polls/', include('polls.urls')), +# path('polls/', include('polls.urls')), path('sifrovacka/', include('sifrovacka.urls')), path('admin/', admin.site.urls), ] diff --git a/requirements.txt b/requirements.txt index 24bf7b73912a053becf24d866391c9166054bfe6..7dd6fb476d59d89ab95cd909c6b0a197771dc553 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,9 @@ asgiref==3.3.4 asn1crypto==0.24.0 +confusable-homoglyphs==3.2.0 cryptography==2.6.1 Django==3.2.3 +django-registration==3.1.2 entrypoints==0.3 keyring==17.1.1 keyrings.alt==3.1.1 diff --git a/sifrovacka/templates/base.html b/sifrovacka/templates/base.html new file mode 100644 index 0000000000000000000000000000000000000000..e024652b13b37ae20bf46bd8de42fadeb9ccfc6c --- /dev/null +++ b/sifrovacka/templates/base.html @@ -0,0 +1,158 @@ +{% load static %} +<!doctype html> +<html lang="cs"> +<head> + <!-- Meta --> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width" /> + {% if settings.SIFROVACKA_ENV == "test" %} + <meta name="robots" content="noindex, nofollow"> + {% endif %} + + <!-- Favicon --> + {% comment%} + {% include "shared/favicon_snippet.html" %} + {% endcomment %} + + <!-- Styles --> + <link href="https://styleguide.pir-test.eu/2.3.x/css/styles.css" rel="stylesheet" media="all" /> + + <style type="text/css"> + .head-alt-md, .head-alt-lg { + line-height: 1.25; + } + .content-block a { + color: #004958; + } + .text-white a { + color: #FFFFFF; + } + a.btn { + text-decoration: none !important; + } + </style> + + {% if settings.SIFROVACKA_ENV == "prod" and settings.ONBOARDING_MATOMO_ID %} + {% include "shared/matomo_snippet.html" with matomo_id=settings.ONBOARDING_MATOMO_ID %} + {% endif %} + + <title>Šifrovačky</title> +</head> + +<body> + + {% if settings.SIFROVACKA_ENV == "test" %} + <div class="bg-yellow-200 p-2 text-center flex-grow"><b>TESTOVACÍ VERZE!</b> Informace nemusejí odpovídat skutečnosti.</div> + {% endif %} + + <nav class="navbar navbar--simple __js-root"> + <div> + <div class="container container--wide navbar__content navbar__content--initialized"> + <div class="navbar__brand my-4 flex items-center lg:pr-8 lg:my-0"> + <a href="/"><img src="https://styleguide.pir-test.eu/2.3.x/images/logo-round-white.svg" class="w-8"></a> + <span class="pl-4 font-bold text-xl lg:border-r lg:border-grey-300 lg:pr-8"> + Šifrovačky + {% if settings.SIFROVACKA_ENV == "dev" %}<sup class="text-cyan-100">(DEV)</sup>{% endif %} + </span> + </div> + <div class="navbar__menutoggle my-4 flex justify-end lg:hidden"> + <a href="#" class="no-underline hover:no-underline"><i class="ico--menu text-3xl"></i></a> + </div> + <div class="navbar__main navbar__section navbar__section--expandable container-padding--zero lg:container-padding--auto flex items-center"> + <div class="flex-grow"> + <ul class="navbar-menu text-white"> + <li class="navbar-menu__item"> + <!--<a href="#" data-href="#" class="navbar-menu__link">Hlavní strana</a>--> + </li> + </ul> + </div> + <div class="flex items-center space-x-4"> + {% if user.is_authenticated %} + <span class="head-heavy-2xs">{{ user }}</span> +{% comment %} +{% endcomment %} + <form action="{% url "accounts/logout" %}" method="post"> + {% csrf_token %} + <button class="text-grey-200 hover:text-white" title="Odhlásit se"><i class="ico--log-out"></i></button> + </form> + {% else %} +{% comment %} +{% endcomment %} + <a class="btn btn--grey-125 btn--hoveractive btn--to-white" href="{% url "accounts/login" %}"> + <div class="btn__body ">přihlášení</div> + </a> + {% endif %} + </div> + </div> + </div> + </div> + </nav> + + {% if messages %} + <div class="container container--default pt-3"> + {% for message in messages %} + <div class="alert alert--{{ message.level_tag }}">{{ message }}</div> + {% endfor %} + </div> + {% endif %} + + <div class="container container--default py-8 lg:py-24"> + <div class="content-block"> + {% block content %}{% endblock %} + </div> + </div> + + <footer class="footer bg-grey-700 text-white __js-root"> + <ui-app inline-template> + <div> + <div class="footer__main py-4 lg:py-16 container container--default"> + <section class="footer__brand"> + <a href="https://www.pirati.cz"> + <img src="https://styleguide.pir-test.eu/2.3.x/images/logo-full-white.svg" alt="logo pirátské strany" class="w-32 md:w-40 pb-6" /> + </a> + <p class="para hidden md:block md:mb-4 lg:mb-0 text-grey-200"> + <span class="copyleft inline-block">©</span> {% now "Y" %} Piráti. Všechna práva vyhlazena. Sdílejte a nechte ostatní sdílet za stejných podmínek. + </p> + </section> + <section class="footer__social lg:text-right"> + <div class="mb-4"> + <div class="social-icon-group space-x-2 text-white pb-4"> + <a href="https://www.pirati.cz" class="social-icon "><i class="ico--home"></i></a> + <a href="https://www.facebook.com/ceska.piratska.strana/" class="social-icon "><i class="ico--facebook"></i></a> + <a href="https://twitter.com/PiratskaStrana" class="social-icon "><i class="ico--twitter"></i></a> + <a href="https://www.youtube.com/user/CeskaPiratskaStrana" class="social-icon "><i class="ico--youtube"></i></a> + <a href="https://www.instagram.com/pirati.cz/" class="social-icon "><i class="ico--instagram"></i></a> + <a href="https://www.flickr.com/photos/pirati/" class="social-icon "><i class="ico--flickr"></i></a> + </div> + </div> + <div class="flex flex-col md:flex-row lg:flex-col lg:items-end space-y-2 md:space-y-0 md:space-x-2 lg:space-x-0 lg:space-y-2"> + <a href="https://dary.pirati.cz" class="btn btn--icon btn--cyan-200 btn--hoveractive text-lg btn--fullwidth sm:btn--autowidth"> + <div class="btn__body-wrap"> + <div class="btn__body ">Přispěj</div> + <div class="btn__icon "> + <i class="ico--pig"></i> + </div> + </div> + </a> + <a href="https://nalodeni.pirati.cz" class="btn btn--icon btn--blue-300 btn--hoveractive text-lg btn--fullwidth sm:btn--autowidth"> + <div class="btn__body-wrap"> + <div class="btn__body ">Naloď se</div> + <div class="btn__icon "> + <i class="ico--anchor"></i> + </div> + </div> + </a> + </div> + </section> + </div> + </div> + </ui-app> + </footer> + + <script src="{% static "shared/vendor/vue/vue.2.6.11.js" %}"></script> + <script src="https://styleguide.pir-test.eu/2.3.x/js/main.bundle.js"></script> + <script src="{% static "shared/vendor/jquery/jquery-3.4.1.min.js" %}"></script> + {% block extra_js %}{% endblock %} +</body> +</html> + diff --git a/sifrovacka/templates/django_registration/login.html b/sifrovacka/templates/django_registration/login.html new file mode 100644 index 0000000000000000000000000000000000000000..2e029badb4d1a3e81a91b3cdc784fe02c23bf5a8 --- /dev/null +++ b/sifrovacka/templates/django_registration/login.html @@ -0,0 +1,45 @@ +{% extends "registration/registration_base.html" %} +{% load i18n %} + +{% block title %}{% trans "Log in" %}{% endblock %} + +{% block content %} +<form method="post" action=""> + {% csrf_token %} + {{ form.as_p }} + <input type="submit" value="{% trans 'Log in' %}" /> + <input type="hidden" name="next" value="{{ next }}" /> +</form> + +<p>{% trans "Forgot your password?" %} <a href="{% url 'auth_password_reset' %}">{% trans "Reset it" %}</a>.</p> +<p>{% trans "Not a member?" %} <a href="{% url 'registration_register' %}">{% trans "Register" %}</a>.</p> +{% endblock %} + + +{% comment %} +**registration/login.html** + +It's your responsibility to provide the login form in a template called +registration/login.html by default. This template gets passed four +template context variables: + +``form`` + A Form object representing the login form. See the forms + documentation for more on Form objects. + +``next`` + The URL to redirect to after successful login. This may contain a + query string, too. + +``site`` + The current Site, according to the SITE_ID setting. If you don't + have the site framework installed, this will be set to an instance + of RequestSite, which derives the site name and domain from the + current HttpRequest. + +``site_name`` + An alias for site.name. If you don't have the site framework + installed, this will be set to the value of + request.META['SERVER_NAME']. For more on sites, see The + "sites" framework. +{% endcomment %} diff --git a/sifrovacka/templates/django_registration/registration_base.html b/sifrovacka/templates/django_registration/registration_base.html new file mode 100644 index 0000000000000000000000000000000000000000..d609d2d1a68f5d607a670c60464cb997df3b8005 --- /dev/null +++ b/sifrovacka/templates/django_registration/registration_base.html @@ -0,0 +1,21 @@ +{% extends "base.html" %} + +<h2>Sign up</h2> + <form method="post"> + {% csrf_token %} + {% for field in form %} + <p> + {{ field.label_tag }}<br> + {{ field }} + {% if field.help_text %} + <small style="color: grey">{{ field.help_text }}</small> + {% endif %} + {% for error in field.errors %} + <p style="color: red">{{ error }}</p> + {% endfor %} + </p> + {% endfor %} + <button type="submit">Sign up</button> + </form> + +{% endblock %} diff --git a/sifrovacka/templates/django_registration/registration_closed.html b/sifrovacka/templates/django_registration/registration_closed.html new file mode 100644 index 0000000000000000000000000000000000000000..ca6de6c26b2377dc4683f7f061c173e5efa46ca2 --- /dev/null +++ b/sifrovacka/templates/django_registration/registration_closed.html @@ -0,0 +1,8 @@ +{% extends "django_registration/registration_base.html" %} +{% load i18n %} + +{% block title %}{% trans "Registration is closed" %}{% endblock %} + +{% block content %} +<p>{% trans "Sorry, but registration is closed at this moment. Come back later." %}</p> +{% endblock %} diff --git a/sifrovacka/templates/django_registration/registration_complete.html b/sifrovacka/templates/django_registration/registration_complete.html new file mode 100644 index 0000000000000000000000000000000000000000..6fea9882817e7bafb02f1302d37acda11f5e9baf --- /dev/null +++ b/sifrovacka/templates/django_registration/registration_complete.html @@ -0,0 +1,18 @@ +{% extends "django_registration/registration_base.html" %} +{% load i18n %} + +{% block title %}{% trans "Activation email sent" %}{% endblock %} + +{% block content %} +<p>{% trans "Please check your email to complete the registration process." %}</p> +{% endblock %} + + +{% comment %} +**registration/registration_complete.html** + +Used after successful completion of the registration form. This +template has no context variables of its own, and should simply inform +the user that an email containing account-activation information has +been sent. +{% endcomment %} diff --git a/sifrovacka/templates/django_registration/registration_form.html b/sifrovacka/templates/django_registration/registration_form.html new file mode 100644 index 0000000000000000000000000000000000000000..7df1faaceb8ecff0975dbdfea1e13aa6f493c3c4 --- /dev/null +++ b/sifrovacka/templates/django_registration/registration_form.html @@ -0,0 +1,25 @@ +{% extends "django_registration/registration_base.html" %} +{% load i18n %} + +{% block title %}{% trans "Register for an account" %}{% endblock %} + +{% block content %} +<form method="post" action=""> + {% csrf_token %} + {{ form.as_p }} + <input type="submit" value="{% trans 'Submit' %}" /> +</form> +{% endblock %} + + +{% comment %} +**registration/registration_form.html** +Used to show the form users will fill out to register. By default, has +the following context: + +``form`` + The registration form. This will be an instance of some subclass + of ``django.forms.Form``; consult `Django's forms documentation + <http://docs.djangoproject.com/en/dev/topics/forms/>`_ for + information on how to display this in a template. +{% endcomment %} diff --git a/sifrovacka/templates/index.html b/sifrovacka/templates/index.html new file mode 100644 index 0000000000000000000000000000000000000000..db7423572a5af384b03c4f1d5dd7307e2d97d25b --- /dev/null +++ b/sifrovacka/templates/index.html @@ -0,0 +1,13 @@ +{% extends "base.html" %} + +{% block content %} +{% if active_sifrovacka_list %} + <ul> + {% for sifrovacka in active_sifrovacka_list %} + <li><a href="/sifrovacka/{{ sifrovacka.id }}/">{{ sifrovacka.sifrovacka_name }}</a></li> + {% endfor %} + </ul> +{% else %} + <p>Žádné šifrovačky nejsou aktivní.</p> +{% endif %} +{% endblock %} diff --git a/sifrovacka/urls.py b/sifrovacka/urls.py index 88a9caca8cebb2a058d9dd370373eee8ec7a89cb..aa564fb5fb70daaf0db84c83da208faf64af0155 100644 --- a/sifrovacka/urls.py +++ b/sifrovacka/urls.py @@ -1,7 +1,11 @@ -from django.urls import path +from django.urls import include,path from . import views urlpatterns = [ + # accounts uls + path('accounts/', include('django_registration.backends.one_step.urls')), + path('accounts/', include('django.contrib.auth.urls')), + # / path('', views.index, name='index'), ] diff --git a/sifrovacka/views.py b/sifrovacka/views.py index 769a8a071f91f09295d8ac600a0830d9f8429411..d5b43ba1239b8c6970ee30d8769979b404a76f88 100644 --- a/sifrovacka/views.py +++ b/sifrovacka/views.py @@ -2,7 +2,18 @@ from django.shortcuts import render # Create your views here. from django.http import HttpResponse +from django.template import loader +from django.contrib.auth import login,logout - +#def index(request): +# return HttpResponse("Hello, world. You're at the polls index.") def index(request): - return HttpResponse("Hello, world. You're at the polls index.") + template = loader.get_template('index.html') + context = {"": ""} + + return HttpResponse(template.render(context, request)) + + + + +