Commit dc67ea31 authored by erdnaxe's avatar erdnaxe 🎇

Regroup everything here

parent e55ec8a2
[run]
source =
note_kfet
note_theme
note_adherents
omit =
note_theme/tests/*.py
note_theme/migrations/*.py
note_adherents/tests/*.py
note_adherents/migrations/*.py
image: python:3.6
stages:
- test
before_script:
- pip install tox
python36:
image: python:3.6
stage: test
script: tox -e py36
python37:
image: python:3.7
stage: test
script: tox -e py37
linters:
stage: test
script: tox -e linters
This diff is collapsed.
# -*- mode: python; coding: utf-8 -*-
# Copyright (C) 2016-2019 by BDE
# SPDX-License-Identifier: GPL-3.0-or-later
from django.conf import settings
from django.contrib.auth.models import User
from django.db import models
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.utils.translation import gettext_lazy as _
class Profile(models.Model):
"""
An user profile
We do not want to patch the Django Contrib Auth User class
so this model add an user profile with additional information.
"""
user = models.OneToOneField(
settings.AUTH_USER_MODEL,
on_delete=models.CASCADE,
)
phone_number = models.CharField(
max_length=255,
verbose_name=_('phone number'),
)
section = models.CharField(
max_length=255,
verbose_name=_('section'),
help_text=_('e.g. "1A0", "9A♥", "SAPHIRE"'),
)
class Meta:
verbose_name = _('user profile')
verbose_name_plural = _('user profile')
def __str__(self):
return self.user.get_username()
class MembershipFee(models.Model):
"""
TODO
"""
user = models.ForeignKey(
settings.AUTH_USER_MODEL,
on_delete=models.PROTECT,
)
date = models.CharField(
max_length=255,
verbose_name=_('phone number'),
)
amount = models.CharField(
max_length=255,
verbose_name=_('section'),
help_text=_('e.g. "1A0", "9A♥", "SAPHIRE"'),
)
class Meta:
verbose_name = _('user profile')
verbose_name_plural = _('user profile')
def __str__(self):
return self.user.get_username()
@receiver(post_save, sender=User)
def save_user_profile(sender, instance, created, **_kwargs):
"""
Hook to save an user profile when an user is updated
"""
if created:
Profile.objects.create(user=instance)
instance.profile.save()
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-06-30 16:26+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: templates/admin/base_site.html:22 templates/base.html:48
msgid "Welcome,"
msgstr ""
#: templates/admin/base_site.html:27
msgid "View site"
msgstr "Retour au site"
#: templates/admin/base_site.html:32 templates/admin/base_site.html:51
#: templates/base.html:52
msgid "View admin"
msgstr "Administration"
#: templates/admin/base_site.html:44
msgid "Documentation"
msgstr ""
#: templates/admin/base_site.html:53 templates/base.html:56
msgid "Log out"
msgstr ""
#: templates/base.html:62 templates/registration/login.html:9
#: templates/registration/login.html:56
msgid "Log in"
msgstr ""
#: templates/registration/logged_out.html:9
#: templates/registration/password_change_done.html:9
#: templates/registration/password_change_form.html:9
#: templates/registration/password_reset_complete.html:9
#: templates/registration/password_reset_confirm.html:9
#: templates/registration/password_reset_done.html:9
#: templates/registration/password_reset_form.html:9
msgid "Home"
msgstr ""
#: templates/registration/login.html:14
msgid "Please correct the error below."
msgstr ""
#: templates/registration/login.html:15
msgid "Please correct the errors below."
msgstr ""
#: templates/registration/login.html:31
#, python-format
msgid ""
"You are authenticated as %(username)s, but are not authorized to access this "
"page. Would you like to login to a different account?"
msgstr ""
#: templates/registration/login.html:52
msgid "Forgotten your password?"
msgstr "Mot de passe oublié ?"
#: templates/registration/password_change_done.html:9
#: templates/registration/password_change_form.html:9
msgid "Password change"
msgstr ""
#: templates/registration/password_reset_complete.html:9
#: templates/registration/password_reset_done.html:9
#: templates/registration/password_reset_form.html:9
msgid "Password reset"
msgstr ""
#: templates/registration/password_reset_confirm.html:9
msgid "Password reset confirmation"
msgstr ""
#: templates/registration/password_reset_email.html:2
#, python-format
msgid ""
"You're receiving this email because you requested a password reset for your "
"user account at %(site_name)s."
msgstr ""
#: templates/registration/password_reset_email.html:4
msgid "Please go to the following page and choose a new password:"
msgstr ""
#: templates/registration/password_reset_email.html:9
msgid "Thanks for using our site!"
msgstr ""
#: templates/registration/password_reset_email.html:11
#, python-format
msgid "The %(site_name)s team"
msgstr ""
/*
* SPDX-License-Identifier: GPL-3.0-or-later
*
* Copyright © 2019 Alexandre Iooss
*
* This is the custom style for Django Contrib Admin
*/
/* Colors */
#header {
background-color: #151515;
border-bottom: solid 5px #d80029;
padding: 10px 40px;
}
.module h2, .module caption, .inline-group h2 {
background: #e6e0d8;
color: #222;
}
a.section:link, a.section:visited {
color: #222;
}
#user-tools a {
border-bottom: none;
font-weight: bold;
}
div.breadcrumbs {
background: #3c3c3c;
}
.button, input[type=submit], input[type=button], .submit-row input, a.button {
background: #d8a456;
}
.button:active, input[type=submit]:active, input[type=button]:active, .button:focus, input[type=submit]:focus,
input[type=button]:focus, .button:hover, input[type=submit]:hover, input[type=button]:hover {
background: #b98d4a;
}
.button.default, input[type=submit].default, .submit-row input.default {
background: #b98d4a;
}
.button.default:active, input[type=submit].default:active, .button.default:focus, input[type=submit].default:focus,
.button.default:hover, input[type=submit].default:hover {
background: #a7752b;
}
/* User tools top menu */
#user-tools .dropdown:hover > a, #user-tools .dropdown:focus > a {
color: #79aec8;
}
#user-tools .dropdown {
position: relative; /* needed to position the dropdown content */
display: inline-block;
}
#user-tools .dropdown-content {
display: block;
position: absolute;
background-color: #444444;
min-width: 180px;
box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2);
z-index: 2000;
text-align: left;
/* Hide menu by making it transparent */
transition: opacity 100ms, visibility 100ms;
opacity: 0;
visibility: hidden;
}
#user-tools .dropdown-content a {
color: #fff;
padding: 7px 8px;
text-decoration: none;
display: block;
line-height: 16px;
}
#user-tools .dropdown-content a:hover {
background-color: #636363;
}
#user-tools .dropdown:hover .dropdown-content {
opacity: 1;
visibility: visible;
}
/* Fix navigation hidden */
#header {
overflow: visible;
}
.login #header {
overflow: hidden;
}
/* Footer */
#footer {
padding: 20px 40px;
color: #999;
}
.login #footer {
padding: 10px;
font-size: 10pt;
}
#footer a {
color: #777;
}
#footer select {
height: 24px;
padding: 0;
}
/* Pull footer to bottom */
#content {
min-height: calc(100vh - 190px);
}
.login #content {
min-height: 0;
}
/* Recenter login button */
.login .submit-row {
padding: 1em 0 0 0 !important;
text-align: center !important;
}
/* Dashboard should take all page */
.dashboard #content {
width: auto;
}
<?xml version="1.0" encoding="utf-8"?>
<browserconfig>
<msapplication>
<tile>
<square150x150logo src="/static/favicon/mstile-150x150.png"/>
<TileColor>#da532c</TileColor>
</tile>
</msapplication>
</browserconfig>
This diff is collapsed.
{
"name": "",
"short_name": "",
"icons": [
{
"src": "/static/favicon/android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/static/favicon/android-chrome-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display": "standalone"
}
{% extends "admin/base.html" %}
{% comment %}
SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %}
{% load i18n staticfiles %}
{% block title %}{{ title }} | {{ request.site.name }}{% endblock %}
{% block branding %}
<strong id="site-name">
<a href="{{ site_url }}">
{{ request.site.name }}
</a>
</strong>
{% endblock %}
{% block usertools %}
{% if user.is_authenticated %}
<div id="user-tools">
{% block welcome-msg %}
{% trans 'Welcome,' %}
<strong>{% firstof user.get_short_name user.get_username %}</strong>.
{% endblock %}
{% block userlinks %}
{% if site_url %}
<a href="{{ site_url }}">{% trans 'View site' %}</a> /
{% endif %}
{% if available_apps %}
{# When in admin site, list all admin pages and documentation #}
<span class="dropdown">
<a href="{% url 'admin:index' %}">{% trans 'View admin' %}</a>
<span class="dropdown-content">
{% for app in available_apps %}
{% for model in app.models %}
{% if model.admin_url %}
<a href="{{ model.admin_url }}">{{ model.name }}</a>
{% endif %}
{% endfor %}
{% endfor %}
{% if user.is_active and user.is_superuser %}
{% url 'django-admindocs-docroot' as docsroot %}
{% if docsroot %}
<a href="{{ docsroot }}">{% trans 'Documentation' %}</a>
{% endif %}
{% endif %}
</span>
</span> /
{% elif user.is_staff %}
{# When not in admin site, but user is staff then add a link #}
<a href="{% url 'admin:index' %}">{% trans 'View admin' %}</a> /
{% endif %}
<a href="{% url 'logout' %}">{% trans 'Log out' %}</a>
{% endblock %}
</div>
{% endif %}
{% endblock %}
{% block extrastyle %}
<link rel="stylesheet" type="text/css" href="{% static "css/admin.css" %}"/>
{# Favicon #}
<link rel="apple-touch-icon" sizes="180x180" href="{% static "favicon/apple-touch-icon.png" %}">
<link rel="icon" type="image/png" sizes="32x32" href="{% static "favicon/favicon-32x32.png" %}">
<link rel="icon" type="image/png" sizes="16x16" href="{% static "favicon/favicon-16x16.png" %}">
<link rel="manifest" href="{% static "favicon/site.webmanifest" %}">
<link rel="mask-icon" href="{% static "favicon/safari-pinned-tab.svg" %}" color="#5bbad5">
<link rel="shortcut icon" href="{% static "favicon/favicon.ico" %}">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="msapplication-config" content="{% static "favicon/browserconfig.xml" %}">
<meta name="theme-color" content="#ffffff">
{% endblock %}
{% block footer %}
{% if not is_popup %}
<div id="footer">
<form action="{% url 'set_language' %}" method="post">
{% csrf_token %}
<select title="language" name="language" onchange="this.form.submit()">
{% get_current_language as LANGUAGE_CODE %}
{% get_available_languages as LANGUAGES %}
{% get_language_info_list for LANGUAGES as languages %}
{% for language in languages %}
<option value="{{ language.code }}"{% if language.code == LANGUAGE_CODE %} selected{% endif %}>
{{ language.name_local }} ({{ language.code }})
</option>
{% endfor %}
</select>
<noscript>
<input type="submit">
</noscript>
Note Kfet 2018-2020 &mdash; <a href="mailto:tresorerie.bde@lists.crans.org">Nous contactez</a>
</form>
</div>
{% endif %}
{% endblock %}
{% extends "registration/logged_out.html" %}
{% comment %}
SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %}
{% load i18n %}
{% block breadcrumbs %}
<div class="breadcrumbs">
<a href="{% url 'index' %}">{% trans 'Home' %}</a>
</div>
{% endblock %}
{% extends "registration/password_change_done.html" %}
{% comment %}
SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %}
{% load i18n %}
{% block breadcrumbs %}
<div class="breadcrumbs">
<a href="{% url 'index' %}">{% trans 'Home' %}</a> &rsaquo; {% trans 'Password change' %}
</div>
{% endblock %}
{% extends "registration/password_change_form.html" %}
{% comment %}
SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %}
{% load i18n %}
{% block breadcrumbs %}
<div class="breadcrumbs">
<a href="{% url 'index' %}">{% trans 'Home' %}</a> &rsaquo; {% trans 'Password change' %}
</div>
{% endblock %}
{% extends "registration/password_reset_complete.html" %}
{% comment %}
SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %}
{% load i18n %}
{% block breadcrumbs %}
<div class="breadcrumbs">
<a href="{% url 'index' %}">{% trans 'Home' %}</a> &rsaquo; {% trans 'Password reset' %}
</div>
{% endblock %}
{% extends "registration/password_reset_confirm.html" %}
{% comment %}
SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %}
{% load i18n %}
{% block breadcrumbs %}
<div class="breadcrumbs">
<a href="{% url 'index' %}">{% trans 'Home' %}</a> &rsaquo; {% trans 'Password reset confirmation' %}
</div>
{% endblock %}
{% extends "registration/password_reset_done.html" %}
{% comment %}
SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %}
{% load i18n %}
{% block breadcrumbs %}
<div class="breadcrumbs">
<a href="{% url 'index' %}">{% trans 'Home' %}</a> &rsaquo; {% trans 'Password reset' %}
</div>
{% endblock %}
{% load i18n %}{% autoescape off %}
{% blocktrans %}You're receiving this email because you requested a password reset for your user account at {{ site_name }}.{% endblocktrans %}
{% trans "Please go to the following page and choose a new password:" %}
{% block reset_link %}
{{ protocol }}://{{ domain }}{% url 'password_reset_confirm' uidb64=uid token=token %}
{% endblock %}
{% trans "Thanks for using our site!" %}
{% blocktrans %}The {{ site_name }} team{% endblocktrans %}
{% endautoescape %}
{% extends "registration/password_reset_form.html" %}
{% comment %}
SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %}
{% load i18n %}
{% block breadcrumbs %}
<div class="breadcrumbs">
<a href="{% url 'index' %}">{% trans 'Home' %}</a> &rsaquo; {% trans 'Password reset' %}
</div>
{% endblock %}
# -*- mode: python; coding: utf-8 -*-
# SPDX-License-Identifier: GPL-3.0-or-later
from django.contrib.auth.models import User
from django.test import TestCase
"""
Test that every themed page still works
"""
class TemplateLoggedOutTests(TestCase):
def test_login_page(self):
response = self.client.get('/admin/login/')
self.assertEqual(response.status_code, 200)
class TemplateLoggedInTests(TestCase):
def setUp(self):
self.user = User.objects.create_superuser(
username="admin",
password="adminadmin",
email="admin@example.com",
)
self.client.force_login(self.user)
def test_login_page(self):
"""
Login page should redirect
"""
response = self.client.get('/admin/login/')
self.assertEqual(response.status_code, 302)
def test_admin_index(self):
response = self.client.get('/admin/')
self.assertEqual(response.status_code, 200)
def test_accounts_password_reset(self):
response = self.client.get('/accounts/password_reset/')
self.assertEqual(response.status_code, 200)
def test_logout_page(self):
response = self.client.get('/accounts/logout/')
self.assertEqual(response.status_code, 200)
[tox]
envlist = py36,py37,linters
skipsdist = True
[testenv]
basepython = python3
deps =
-r{toxinidir}/requirements.txt
coverage
commands =
coverage run ./manage.py test {posargs}
coverage report -m
[testenv:pre-commit]
deps = pre-commit
commands =
pre-commit run --all-files --show-diff-on-failure
[testenv:linters]
deps =
-r{toxinidir}/requirements.txt
flake8
flake8-colors
flake8-import-order
flake8-typing-imports
pep8-naming
pyflakes
pylint
commands =
flake8 note_*
pylint .
[flake8]
ignore = D203, W503, E203
exclude =
.tox,
.git,
__pycache__,
build,
dist,
*.pyc,
*.egg-info,
.cache,
.eggs
max-complexity = 10
import-order-style = google
application-import-names = flake8
format = ${cyan}%(path)s${reset}:${yellow_bold}%(row)d${reset}:${green_bold}%(col)d${reset}: ${red_bold}%(code)s${reset} %(text)s
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment