diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d6e05525fe817c5f718b720c3d2e3f7d7bd41328..a9acc0a6cde943b70dfbf8a1dea3b336021fd871 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -65,6 +65,7 @@ deploy_demo-master: - grep -v "build:" docker-compose.yml | ssh root@demo-master.biscuit-sis.org env BISCUIT_IMAGE_TAG=${CI_COMMIT_REF_NAME} NGINX_HTTP_PORT=80 + BISCUIT_maintenance__debug=true docker-compose -p biscuit-${CI_ENVIRONMENT_SLUG} -f /dev/stdin diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 74f35ea4898a7e78de7d9927504601da7f442aee..6d394aa73ddf8bdb3edd5938c373475be7063139 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -82,6 +82,26 @@ giving the user control over these decisions is not possible. Developers need to decide what should resonably be followed. +The case on supporting non-free services +---------------------------------------- + +Defined by the `Free Software Definition`_, it is an essential freedom to +be allowed to use free software for any purpose, without limitation. Thus, +interoperability with non-free services shall not be ruled out, and the +BiscuIT project explicitly welcomes implementing support for +interoperability with non-free services. + +However, to purposefullt foster free software and services, if +interoperability for a certain kind of non-free service is implemented, this +must be done in a generalised manner (i.e. using open protocols and +interfaces). For example, if implementing interoperability with some +cloud-hosted calendar provider can be implemented either through a +proprietary API, or through a standard iCalendar/Webcal interfaces, the +latter is to be preferred. Lacking such support, if a proprietary service +is connected through a proprietary, single-purpose interface, measures shall +be taken to also support alternative free services. + + Text documents -------------- @@ -105,4 +125,5 @@ licence possible. .. _Sane software manifesto: https://sane-software.globalcode.info/ .. _Accessibility Manifesto: http://accessibilitymanifesto.com/ .. _User Data Manifesto: https://userdatamanifesto.org/ +.. _Free Software Definition: https://www.gnu.org/philosophy/free-sw.en.html .. _reStructuredText: http://docutils.sourceforge.net/rst.html diff --git a/Dockerfile b/Dockerfile index ec6f771d02496a26629df0f0959af7ff7cbf69c3..ca2bd593107ebc2485daf0d8e85ae6bca208b608 100644 --- a/Dockerfile +++ b/Dockerfile @@ -42,8 +42,7 @@ RUN mkdir -p /var/lib/biscuit/media /var/lib/biscuit/static /var/lib/biscuit/bac # Build messages and assets RUN python manage.py compilemessages; \ - python manage.py yarn install; \ - python manage.py collectstatic --no-input --clear + python manage.py yarn install # Clean up build dependencies RUN apt-get remove --purge -y \ @@ -56,9 +55,7 @@ RUN apt-get remove --purge -y \ apt-get clean -y; \ pip uninstall -y poetry; \ rm -f /var/lib/apt/lists/*_*; \ - rm -rf /root/.cache; \ - rm -rf biscuit/node_modules; \ - rm -rf /usr/local/lib/node_modules + rm -rf /root/.cache # Declare a persistent volume for all data VOLUME /var/lib/biscuit diff --git a/biscuit/core/menus.py b/biscuit/core/menus.py index a230037f8305813cd5ec1a13307894af9da4bc15..a3ba09e29e7a459c7b1a25a20c35cb425c4dcb17 100644 --- a/biscuit/core/menus.py +++ b/biscuit/core/menus.py @@ -96,16 +96,6 @@ MENUS = { } ] }, - { - 'name': _('Support'), - 'url': '#', - 'submenu': [ - { - 'name': _('Get support'), - 'url': 'contact_form' - } - ] - } ], 'DATA_MANAGEMENT_MENU': [ ], diff --git a/biscuit/core/migrations/0006_create_superuser.py b/biscuit/core/migrations/0006_create_superuser.py new file mode 100644 index 0000000000000000000000000000000000000000..861dee94e738bccea983c7e94093d8b24923bb1e --- /dev/null +++ b/biscuit/core/migrations/0006_create_superuser.py @@ -0,0 +1,26 @@ +# Generated by Django 2.2.8 on 2019-12-09 21:04 + +from django.contrib.auth import get_user_model +from django.db import migrations + + +def create_superuser(apps, schema_editor): + User = get_user_model() + + if not User.objects.filter(is_superuser=True).exists(): + User.objects.create_superuser( + username='admin', + email='root@example.com', + password='admin' + ).save() + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0005_unlink_school'), + ] + + operations = [ + migrations.RunPython(create_superuser) + ] diff --git a/biscuit/core/settings.py b/biscuit/core/settings.py index 61c92d3ea50a109873dbdb3e13f8e1bbd4100f9c..f70853445f219c1492daacc0ac4fdd904e41a217 100644 --- a/biscuit/core/settings.py +++ b/biscuit/core/settings.py @@ -34,7 +34,9 @@ DEBUG = _settings.get('maintenance.debug', False) INTERNAL_IPS = _settings.get('maintenance.internal_ips', []) DEBUG_TOOLBAR_CONFIG = { 'RENDER_PANELS': True, - 'SHOW_COLLAPSED': True + 'SHOW_COLLAPSED': True, + 'JQUERY_URL': '', + 'SHOW_TOOLBAR_CALLBACK': 'biscuit.core.util.core_helpers.dt_show_toolbar' } ALLOWED_HOSTS = _settings.get('http.allowed_hosts', []) @@ -65,7 +67,6 @@ INSTALLED_APPS = [ 'menu_generator', 'phonenumber_field', 'debug_toolbar', - 'contact_form', 'django_select2', 'hattori', 'django_otp.plugins.otp_totp', @@ -89,7 +90,6 @@ STATICFILES_FINDERS = [ MIDDLEWARE = [ # 'django.middleware.cache.UpdateCacheMiddleware', - 'debug_toolbar.middleware.DebugToolbarMiddleware', 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.locale.LocaleMiddleware', @@ -97,6 +97,7 @@ MIDDLEWARE = [ 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'debug_toolbar.middleware.DebugToolbarMiddleware', 'django_otp.middleware.OTPMiddleware', 'impersonate.middleware.ImpersonateMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', diff --git a/biscuit/core/templates/contact_form/contact_form.html b/biscuit/core/templates/contact_form/contact_form.html deleted file mode 100644 index 00a6caad94102e477bea534a638846baffcb2fe9..0000000000000000000000000000000000000000 --- a/biscuit/core/templates/contact_form/contact_form.html +++ /dev/null @@ -1,17 +0,0 @@ -{# -*- engine:django -*- #} -{% extends "core/base.html" %} -{% load bootstrap4 i18n %} - -{% block page_title %}BiscuIT SIS support{% endblock %} - -{% block content %} - <h1>{% blocktrans %}Get support{% endblocktrans %}</h1> - - <form method="post"> - {% csrf_token %} - {% bootstrap_form form %} - <button type="submit" class="btn btn-dark"> - {% blocktrans %}Send{% endblocktrans %} - </button> - </form> -{% endblock %} diff --git a/biscuit/core/templates/contact_form/contact_form.txt b/biscuit/core/templates/contact_form/contact_form.txt deleted file mode 100644 index 9a8f66d94083d6ab9dd9abb4a1ade3ffc0ee150c..0000000000000000000000000000000000000000 --- a/biscuit/core/templates/contact_form/contact_form.txt +++ /dev/null @@ -1,3 +0,0 @@ -From: {{ name }} <{{ email }}> - -{{ body }} diff --git a/biscuit/core/templates/contact_form/contact_form_sent.html b/biscuit/core/templates/contact_form/contact_form_sent.html deleted file mode 100644 index 86d69b579fb81370e4842f88edf2f7263986de45..0000000000000000000000000000000000000000 --- a/biscuit/core/templates/contact_form/contact_form_sent.html +++ /dev/null @@ -1,13 +0,0 @@ -{# -*- engine:django -*- #} -{% extends "core/base.html" %} -{% load bootstrap4 i18n %} - -{% block page_title %}BiscuIT School Information System (SIS){% endblock %} - -{% block content %} - <div class="alert alert-success" role="alert"> - {% blocktrans %} - The message was successfully submitted. - {% endblocktrans %} - </div> -{% endblock %} diff --git a/biscuit/core/templates/contact_form/contact_form_subject.txt b/biscuit/core/templates/contact_form/contact_form_subject.txt deleted file mode 100644 index 5fcb23b2da374cb55dc32f3795caf0b3579334ec..0000000000000000000000000000000000000000 --- a/biscuit/core/templates/contact_form/contact_form_subject.txt +++ /dev/null @@ -1 +0,0 @@ -[BiscuIT Support] diff --git a/biscuit/core/urls.py b/biscuit/core/urls.py index dd98dc0175b1e6a13605208615f6fa2ca1482342..0ecfbb6f34d064a32170999f3886327100a6da9d 100644 --- a/biscuit/core/urls.py +++ b/biscuit/core/urls.py @@ -34,7 +34,6 @@ urlpatterns = [ path('group/<int:id_>/edit', views.edit_group, name='edit_group_by_id'), path('', views.index, name='index'), path('maintenance-mode/', include('maintenance_mode.urls')), - path('contact/', include('contact_form.urls')), path('impersonate/', include('impersonate.urls')), path('__i18n__/', include('django.conf.urls.i18n')), path('select2/', include('django_select2.urls')), diff --git a/biscuit/core/util/core_helpers.py b/biscuit/core/util/core_helpers.py index e8c0b1fe28c167b25f39eae946077c2d28832723..03ec0f6391811d62d22b002d4765816f74119115 100644 --- a/biscuit/core/util/core_helpers.py +++ b/biscuit/core/util/core_helpers.py @@ -2,9 +2,23 @@ from importlib import import_module import pkgutil from typing import Sequence +from django.conf import settings from django.http import HttpRequest +def dt_show_toolbar(request: HttpRequest) -> bool: + from debug_toolbar.middleware import show_toolbar # noqa + + if not settings.DEBUG: + return False + + if show_toolbar(request): + return True + elif hasattr(request, 'user') and request.user.is_superuser: + return True + + return False + def get_app_packages() -> Sequence[str]: """ Find all packages within the biscuit.apps namespace. """ diff --git a/docker-compose.yml b/docker-compose.yml index e71f2f1dd9fcd1b815995b4c6ca999a1ce66d715..ca09c5af38ebb0f79d60d0794d0a882ba4ceaace 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -19,6 +19,7 @@ services: - BISCUIT_http__allowed_hosts="['*']" - BISCUIT_caching__memcached__address=memcached:11211 - BISCUIT_database__host=db + - BISCUIT_maintenance__debug=${BISCUIT_maintenance__debug:-false} depends_on: - db - memcached diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 4dcf89fce710430ead493366a36f26863dffcd69..eb1668a08a600197c2abb0b20813e8aff433b9cf 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -19,6 +19,7 @@ done python manage.py flush --no-input python manage.py migrate +python manage.py collectstatic --no-input --clear if [[ -n "$@" ]]; then exec "$@" diff --git a/docker/nginx/Dockerfile b/docker/nginx/Dockerfile index e47ed67f547c508c1d18dc5ae6184f1fef90f873..4f5a2cd405ea5ff980d523df687de50e4835a6f3 100644 --- a/docker/nginx/Dockerfile +++ b/docker/nginx/Dockerfile @@ -1,6 +1,6 @@ FROM nginx RUN rm /etc/nginx/conf.d/default.conf -COPY nginx.conf /etc/nginx/conf.d +COPY nginx.conf /etc/nginx/conf.d/default.conf RUN mkdir /var/lib/biscuit diff --git a/poetry.lock b/poetry.lock index 226b6ce8a57eb1dc5b5ac360510e71a7fb72e90d..50960dbe1af5febeefe0ae788a6658270b74c563 100644 --- a/poetry.lock +++ b/poetry.lock @@ -204,17 +204,6 @@ version = "0.9.2" [package.dependencies] Django = ">=1.8.0" -[[package]] -category = "main" -description = "A generic contact-form application for Django" -name = "django-contact-form" -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" -version = "1.7" - -[package.dependencies] -Django = ">=1.11" - [[package]] category = "main" description = "Running python crons in a Django project" @@ -1303,7 +1292,7 @@ more-itertools = "*" ldap = ["django-auth-ldap"] [metadata] -content-hash = "908e1e56f87aef8ccff2ce9a79bf335b5cb09896566d1dddb45c62c799c86310" +content-hash = "bce86bce11298566a201539a09dd1f1123f3d1e48725419fcac72009f154cebe" python-versions = "^3.7" [metadata.hashes] @@ -1328,7 +1317,6 @@ django-auth-ldap = ["4d68d21058bd57a316a9e1fcd7a36d0f25d054d4d9d9ec85f766a499117 django-bootstrap4 = ["3da770392819267eda2f774bcf832460af00db21089b94caf4df94be8a48c48c"] django-bulk-update = ["49a403392ae05ea872494d74fb3dfa3515f8df5c07cc277c3dc94724c0ee6985", "5ab7ce8a65eac26d19143cc189c0f041d5c03b9d1b290ca240dc4f3d6aaeb337"] django-common-helpers = ["2d56be6fa261d829a6a224f189bf276267b9082a17d613fe5f015dd4d65c17b4"] -django-contact-form = ["b42b7e04d6af3318b8427c1eaf62385ec66da252aa79b607ee55d956c7af4a2d", "c31f73faa13f52efa81ac95f41007f3a84eca617f92773a1bed7ca90c61cb3ed"] django-cron = ["08d22708c8b2ecab8cda989019a66c7e1e2424c59d822796fd45abf7731d261d"] django-dbbackup = ["9470e5d8bdaee4feb878b1b66c59eb9b27a131cccd648bf7cbfe70930acd4fc0"] django-dbsettings = ["e3147ced54b7db3371df10df8845e4514aeae96720000bca1a01d0a6490a1404"] diff --git a/pyproject.toml b/pyproject.toml index 456e9d434956b95ea80d311aaabf06f6b8379ebe..c4c341b2f0906c0bf786bc6d32a5d88bcec4f031 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,7 +41,6 @@ django-maintenance-mode = "^0.13.3" django-ipware = "^2.1" easy-thumbnails = "^2.6" django-image-cropping = "^1.2" -django-contact-form = "^1.7" django-impersonate = "^1.4" python-memcached = "^1.59" django-dbbackup = "^3.2"