From 0ed808d8d02dd22fe38893e03798c5342d2987c6 Mon Sep 17 00:00:00 2001 From: Julian Dehm Date: Wed, 23 Oct 2024 15:35:59 +0200 Subject: [PATCH] remove or unused stuff from user app --- .../templates/euth_accounts/base_account.html | 5 +- euth/users/management/__init__.py | 0 euth/users/management/commands/__init__.py | 0 .../management/commands/import_a3_users.py | 49 ----------- euth/users/static/users/js/user_search.js | 72 ---------------- euth/users/static/users/js/user_timezone.js | 4 - .../templates/euth_users/indicator_menu.html | 34 -------- euth/users/templatetags/__init__.py | 0 euth/users/templatetags/avatar.py | 8 -- euth/users/templatetags/userindicator.py | 11 --- euth_wagtail/assets/scss/all.scss | 1 - .../scss/components/_user-indicator.scss | 84 ------------------- euth_wagtail/templates/includes/top_menu.html | 4 +- 13 files changed, 2 insertions(+), 270 deletions(-) delete mode 100644 euth/users/management/__init__.py delete mode 100644 euth/users/management/commands/__init__.py delete mode 100644 euth/users/management/commands/import_a3_users.py delete mode 100644 euth/users/static/users/js/user_search.js delete mode 100644 euth/users/static/users/js/user_timezone.js delete mode 100644 euth/users/templates/euth_users/indicator_menu.html delete mode 100644 euth/users/templatetags/__init__.py delete mode 100644 euth/users/templatetags/avatar.py delete mode 100644 euth/users/templatetags/userindicator.py delete mode 100644 euth_wagtail/assets/scss/components/_user-indicator.scss diff --git a/euth/accounts/templates/euth_accounts/base_account.html b/euth/accounts/templates/euth_accounts/base_account.html index cf8c4bf75..bfe6c2d32 100644 --- a/euth/accounts/templates/euth_accounts/base_account.html +++ b/euth/accounts/templates/euth_accounts/base_account.html @@ -1,5 +1,5 @@ {% extends "base.html" %} -{% load i18n thumbnail avatar %} +{% load i18n %} {% block meta_viewport %}{% endblock %} @@ -8,9 +8,6 @@
diff --git a/euth/users/management/__init__.py b/euth/users/management/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/euth/users/management/commands/__init__.py b/euth/users/management/commands/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/euth/users/management/commands/import_a3_users.py b/euth/users/management/commands/import_a3_users.py deleted file mode 100644 index 5306ea8a9..000000000 --- a/euth/users/management/commands/import_a3_users.py +++ /dev/null @@ -1,49 +0,0 @@ -import csv - -from allauth.account.models import EmailAddress -from django.core.management.base import BaseCommand -from django.db import models - -from euth.users.models import User - - -class Command(BaseCommand): - help = 'Import users from csv file exported with A3' - - def add_arguments(self, parser): - parser.add_argument('inputfile', type=str) - - def handle(self, inputfile, *args, **options): - with open(inputfile) as f: - reader = csv.DictReader(f, delimiter=';') - - for user in reader: - self._add_user(user) - - def _add_user(self, userdata): - email = userdata['Email'] - username = userdata['Username'] - - user_exists = User.objects.filter( - models.Q(email=email) - | models.Q(username=username)) - - email_exists = EmailAddress.objects.filter(email=email) - - if user_exists or email_exists: - print('Skipping user {} <{}>'.format(username, email)) - else: - user = User( - username=username, - email=email, - date_joined=userdata['Creation date'], - password="bcrypt$" + userdata['Password hash'], - ) - user.save() - email = EmailAddress( - user=user, - email=userdata['Email'], - verified=True, - primary=True, - ) - email.save() diff --git a/euth/users/static/users/js/user_search.js b/euth/users/static/users/js/user_search.js deleted file mode 100644 index e6425a821..000000000 --- a/euth/users/static/users/js/user_search.js +++ /dev/null @@ -1,72 +0,0 @@ -const $ = require('jquery') - -class UserSearch { - constructor (typeaheadElem) { - this.element = typeaheadElem - this.$element = $(typeaheadElem) - this.identifier = this.$element.data('identifier') - - this.$element.typeahead({ - hint: true, - highlight: true, - minLength: 1 - }, { - name: 'users', - limit: 100, - source: this.findMatches, - display: this.getDisplay, - templates: { - suggestion: this.renderSuggestions - } - }) - // Announce select only if there's an identifier, otherwise it's not needed. - - if (this.identifier) { - this.$element.on('typeahead:select', this.selectHandler.bind(this)) - } - } - - renderSuggestions (context) { - const avatar = context.avatar ? context.avatar : context.avatar_fallback - return ( - `
- ${context.username} -
` - ) - } - - findMatches (q, cb, acb) { - $.get('/api/users?search=' + q, function (results) { - acb(results) - }) - } - - getDisplay (context) { - return context.username - } - - selectHandler (event, context) { - if (window.adhocracy4 && window.adhocracy4.userList && window.adhocracy4.userList[this.identifier]) { - const listeningComponents = window.adhocracy4.userList[this.identifier] - for (let i = 0; i < listeningComponents.length; i++) { - const userList = listeningComponents[i] - userList.add(context).done((data, status) => { - if (status !== 'success') { - return console.error(data, status) - } - this.$element.typeahead('val', '') - }) - } - } - } -} - -$(function () { - const typeaheadElems = document.querySelectorAll('.typeahead') - const length = typeaheadElems.length - const userSearchs = [] - for (let i = 0; i < length; i++) { - const elem = typeaheadElems[i] - userSearchs.push(new UserSearch(elem)) - } -}) diff --git a/euth/users/static/users/js/user_timezone.js b/euth/users/static/users/js/user_timezone.js deleted file mode 100644 index 15c3c1115..000000000 --- a/euth/users/static/users/js/user_timezone.js +++ /dev/null @@ -1,4 +0,0 @@ -(function ($) { - const userTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone - $('#id_timezone').val(userTimezone) -})(window.jQuery) diff --git a/euth/users/templates/euth_users/indicator_menu.html b/euth/users/templates/euth_users/indicator_menu.html deleted file mode 100644 index a81cb7df1..000000000 --- a/euth/users/templates/euth_users/indicator_menu.html +++ /dev/null @@ -1,34 +0,0 @@ -{% load i18n avatar %} - - diff --git a/euth/users/templatetags/__init__.py b/euth/users/templatetags/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/euth/users/templatetags/avatar.py b/euth/users/templatetags/avatar.py deleted file mode 100644 index 20e8ae512..000000000 --- a/euth/users/templatetags/avatar.py +++ /dev/null @@ -1,8 +0,0 @@ -from django import template - -register = template.Library() - - -@register.simple_tag() -def get_avatar(user, size_alias): - return user.avatar_fallback diff --git a/euth/users/templatetags/userindicator.py b/euth/users/templatetags/userindicator.py deleted file mode 100644 index 6e2edbe83..000000000 --- a/euth/users/templatetags/userindicator.py +++ /dev/null @@ -1,11 +0,0 @@ -from django import template - -from .. import sanitize_next - -register = template.Library() - - -@register.inclusion_tag('euth_users/indicator_menu.html', takes_context=True) -def userindicator_menu(context): - context['redirect_field_value'] = sanitize_next(context['request']) - return context diff --git a/euth_wagtail/assets/scss/all.scss b/euth_wagtail/assets/scss/all.scss index 657eac798..f38906d1d 100644 --- a/euth_wagtail/assets/scss/all.scss +++ b/euth_wagtail/assets/scss/all.scss @@ -85,7 +85,6 @@ @import "components/sort-dropdown"; @import "components/document"; @import "components/info-note"; -@import "components/user-indicator"; @import "components/usercontent"; @import "components/dropdown"; @import "components/error-pages"; diff --git a/euth_wagtail/assets/scss/components/_user-indicator.scss b/euth_wagtail/assets/scss/components/_user-indicator.scss deleted file mode 100644 index 02aeba607..000000000 --- a/euth_wagtail/assets/scss/components/_user-indicator.scss +++ /dev/null @@ -1,84 +0,0 @@ -:target:before { - content: ""; - display: block; - height: 80px; /* fixed header height */ - margin: -80px 0 0; /* negative fixed header height */ -} - -.user-indicator .btngroup .dropdown-item { - border-bottom: none; - width: 100%; -} - -.user-indicator .btngroup > a { - height: 45px; -} - -.user-indicator a.btn { - background-color: $brand-brand5; - color: $body-bg; - min-width: 45px; -} - -.user-indicator { - a.dropdown-item:active { - color: $body-bg !important; - background-color: $brand-brand1 !important; - } -} - -.user-indicator > li > a > .inner { - border: none; - display: inline-block; - position: static; - padding-left: $spacer; -} - -.user-indicator .circled { - margin-top: -3px; - margin-right: 10px; -} - -.user-indicator .dropdown-menu { - width: 100%; - border-radius: 0; - background: $body-bg; - overflow-x: hidden; -} - -.user-indicator .btngroup { - display: flex; - flex-wrap: wrap; -} - -.user-indicator .userindicator-profile { - flex-grow: 1; - text-align: left; -} - -.user-indicator .dropdown-toggle { - flex-grow: 0; -} - -@media screen and (min-width: $screen-xs-min) { - .user-indicator > .btngroup, - .user-indicator > .dropdown { - margin-top: 0.4 * $spacer; - } - - .user-indicator .btngroup > a { - display: block; - height: 50px; - padding: 0.875rem 10px; - } - - .user-indicator > li > a > .inner { - padding: 0; - } - - .user-indicator .dropdown-menu { - width: auto; - max-height: 80vh; - overflow-y: auto; - } -} diff --git a/euth_wagtail/templates/includes/top_menu.html b/euth_wagtail/templates/includes/top_menu.html index 9583f6a99..19eed9405 100644 --- a/euth_wagtail/templates/includes/top_menu.html +++ b/euth_wagtail/templates/includes/top_menu.html @@ -1,4 +1,4 @@ -{% load i18n static url_translations wagtailcore_tags userindicator base_tags %} +{% load i18n static url_translations wagtailcore_tags base_tags %} {% get_current_language as LANGUAGE_CODE %} {% load_site_menu "topmenu" as top_menu_items %} @@ -32,8 +32,6 @@