~homeworkprod/byceps

929ad3e9fd28ce912eebf66f839af21cbddcf765 — Jochen Kupperschmidt 5 months ago 2ad53f3
Add `archived` flag to brand

DDL/SQL to update datebase:

    ALTER TABLE brands ADD COLUMN archived boolean;
    UPDATE brands SET archived = false;
    ALTER TABLE brands ALTER COLUMN archived SET NOT NULL;
M byceps/blueprints/admin/brand/forms.py => byceps/blueprints/admin/brand/forms.py +2 -1
@@ 7,7 7,7 @@ byceps.blueprints.admin.brand.forms
"""

from flask_babel import lazy_gettext
from wtforms import StringField
from wtforms import BooleanField, StringField
from wtforms.validators import InputRequired, Length, Optional

from ....util.l10n import LocalizedForm


@@ 30,6 30,7 @@ class UpdateForm(_BaseForm):
    image_filename = StringField(
        lazy_gettext('Image filename'), validators=[Optional()]
    )
    archived = BooleanField(lazy_gettext('archived'))


class EmailConfigUpdateForm(LocalizedForm):

M byceps/blueprints/admin/brand/templates/admin/brand/index.html => byceps/blueprints/admin/brand/templates/admin/brand/index.html +7 -1
@@ 2,6 2,7 @@
{% from 'macros/admin.html' import render_extra_in_heading %}
{% from 'macros/admin/brand.html' import render_brand_avatar %}
{% from 'macros/icons.html' import render_icon %}
{% from 'macros/misc.html' import render_tag %}
{% set current_page = 'brands_admin' %}
{% set title = _('Brands') %}



@@ 24,7 25,7 @@
  <table class="index wide">
    <thead>
      <tr>
        <th>{{ _('Name') }}<br>{{ _('ID') }}</th>
        <th colspan="2">{{ _('Name') }}<br>{{ _('ID') }}</th>
        <th class="centered">{{ _('Parties') }}</th>
        <th class="centered">{{ _('Organizers') }}</th>
      </tr>


@@ 39,6 40,11 @@
            {{ brand.id }}
          </div>
        </td>
        <td>
        {%- if brand.archived %}
          {{ render_tag('archived', class='color-disabled', icon='archived') }}
        {%- endif %}
        </td>
        <td class="centered bignumber">{{ party_count_by_brand_id[brand.id] }}</td>
        <td class="centered bignumber">{{ orga_count_by_brand_id[brand.id] }}</td>
      </tr>

M byceps/blueprints/admin/brand/templates/admin/brand/update_form.html => byceps/blueprints/admin/brand/templates/admin/brand/update_form.html +2 -1
@@ 1,6 1,6 @@
{% extends 'layout/admin/base.html' %}
{% from 'macros/admin.html' import render_backlink %}
{% from 'macros/forms.html' import form_buttons, form_field, form_fieldset %}
{% from 'macros/forms.html' import form_buttons, form_field, form_field_checkbox, form_fieldset %}
{% from 'macros/icons.html' import render_icon %}
{% set current_page = 'brands_admin' %}
{% set current_page_brand = brand %}


@@ 18,6 18,7 @@
    {% call form_fieldset() %}
      {{ form_field(form.title, maxlength=40, autofocus='autofocus') }}
      {{ form_field(form.image_filename) }}
      {{ form_field_checkbox(form.archived, form.archived.label.text) }}
    {% endcall %}

    {{ form_buttons(_('Save')) }}

M byceps/blueprints/admin/brand/templates/admin/brand/view.html => byceps/blueprints/admin/brand/templates/admin/brand/view.html +7 -1
@@ 1,6 1,7 @@
{% extends 'layout/admin/base.html' %}
{% from 'macros/admin.html' import render_extra_in_heading %}
{% from 'macros/icons.html' import render_icon %}
{% from 'macros/misc.html' import render_tag %}
{% set current_page = 'brand_admin' %}
{% set current_page_brand = brand %}
{% set title = brand.title %}


@@ 14,7 15,12 @@
          <li><a href="{{ url_for('.index') }}">{{ _('Brands') }}</a></li>
        </ol>
      </nav>
      <h1>{{ brand.title }}</h1>
      <h1>
        {{ brand.title }}
        {%- if brand.archived %}
        <br>{{ render_tag('archived', class='color-disabled', icon='archived') }}
        {%- endif %}
      </h1>
    </div>
  {%- if has_current_user_permission(BrandPermission.update) %}
    <div class="column-auto">

M byceps/blueprints/admin/brand/views.py => byceps/blueprints/admin/brand/views.py +4 -1
@@ 133,8 133,11 @@ def update(brand_id):

    title = form.title.data.strip()
    image_filename = form.image_filename.data.strip() or None
    archived = form.archived.data

    brand = brand_service.update_brand(brand.id, title, image_filename)
    brand = brand_service.update_brand(
        brand.id, title, image_filename, archived
    )

    flash_success(
        gettext('Brand "%(title)s" has been updated.', title=brand.title)

M byceps/services/brand/dbmodels/brand.py => byceps/services/brand/dbmodels/brand.py +1 -0
@@ 21,6 21,7 @@ class Brand(db.Model):
    id = db.Column(db.UnicodeText, primary_key=True)
    title = db.Column(db.UnicodeText, unique=True, nullable=False)
    image_filename = db.Column(db.UnicodeText, nullable=True)
    archived = db.Column(db.Boolean, default=False, nullable=False)

    def __init__(
        self,

M byceps/services/brand/service.py => byceps/services/brand/service.py +6 -1
@@ 28,13 28,17 @@ def create_brand(brand_id: BrandID, title: str) -> Brand:


def update_brand(
    brand_id: BrandID, title: str, image_filename: Optional[str]
    brand_id: BrandID,
    title: str,
    image_filename: Optional[str],
    archived: bool,
) -> Brand:
    """Update a brand."""
    brand = _get_db_brand(brand_id)

    brand.title = title
    brand.image_filename = image_filename
    brand.archived = archived

    db.session.commit()



@@ 104,4 108,5 @@ def _db_entity_to_brand(brand: DbBrand) -> Brand:
        brand.title,
        brand.image_filename,
        image_url_path,
        brand.archived,
    )

M byceps/services/brand/transfer/models.py => byceps/services/brand/transfer/models.py +1 -0
@@ 18,6 18,7 @@ class Brand:
    title: str
    image_filename: Optional[str]
    image_url_path: Optional[str]
    archived: bool


@dataclass(frozen=True)

M byceps/translations/de/LC_MESSAGES/messages.po => byceps/translations/de/LC_MESSAGES/messages.po +39 -38
@@ 87,8 87,8 @@ msgstr "Neues Passwort setzen"

#: byceps/blueprints/admin/board/forms.py:18
#: byceps/blueprints/admin/brand/forms.py:25
#: byceps/blueprints/admin/brand/templates/admin/brand/index.html:27
#: byceps/blueprints/admin/brand/templates/admin/brand/view.html:30
#: byceps/blueprints/admin/brand/templates/admin/brand/index.html:28
#: byceps/blueprints/admin/brand/templates/admin/brand/view.html:36
#: byceps/blueprints/admin/news/forms.py:24
#: byceps/blueprints/admin/party/forms.py:50
#: byceps/blueprints/admin/shop/storefront/forms.py:38


@@ 213,7 213,7 @@ msgstr "Erstellen"

#: byceps/blueprints/admin/board/templates/admin/board/category_update_form.html:24
#: byceps/blueprints/admin/brand/templates/admin/brand/email_config_update_form.html:24
#: byceps/blueprints/admin/brand/templates/admin/brand/update_form.html:23
#: byceps/blueprints/admin/brand/templates/admin/brand/update_form.html:24
#: byceps/blueprints/admin/news/templates/admin/news/image_update_form.html:24
#: byceps/blueprints/admin/news/templates/admin/news/item_update_form.html:25
#: byceps/blueprints/admin/orga/templates/admin/orga/create_orgaflag_form.html:22


@@ 249,18 249,24 @@ msgstr "Speichern"
msgid "Image filename"
msgstr "Bild-Dateiname"

#: byceps/blueprints/admin/brand/forms.py:37
#: byceps/blueprints/admin/brand/templates/admin/brand/view.html:72
#: byceps/blueprints/admin/brand/forms.py:33
#: byceps/blueprints/admin/party/forms.py:60
#: byceps/blueprints/admin/site/forms.py:90
msgid "archived"
msgstr "archiviert"

#: byceps/blueprints/admin/brand/forms.py:38
#: byceps/blueprints/admin/brand/templates/admin/brand/view.html:78
msgid "Sender address"
msgstr "Absender-Adresse"

#: byceps/blueprints/admin/brand/forms.py:40
#: byceps/blueprints/admin/brand/templates/admin/brand/view.html:76
#: byceps/blueprints/admin/brand/forms.py:41
#: byceps/blueprints/admin/brand/templates/admin/brand/view.html:82
msgid "Sender name"
msgstr "Absender-Name"

#: byceps/blueprints/admin/brand/forms.py:43
#: byceps/blueprints/admin/brand/templates/admin/brand/view.html:80
#: byceps/blueprints/admin/brand/forms.py:44
#: byceps/blueprints/admin/brand/templates/admin/brand/view.html:86
msgid "Contact address"
msgstr "Kontaktadresse"



@@ 269,12 275,12 @@ msgstr "Kontaktadresse"
msgid "Brand \"%(title)s\" has been created."
msgstr "Die Marke \"%(title)s\" wurde angelegt."

#: byceps/blueprints/admin/brand/views.py:142
#: byceps/blueprints/admin/brand/views.py:143
#, python-format
msgid "Brand \"%(title)s\" has been updated."
msgstr "Die Marke \"%(title)s\" wurde aktualisiert."

#: byceps/blueprints/admin/brand/views.py:197
#: byceps/blueprints/admin/brand/views.py:198
msgid "Email configuration has been updated."
msgstr "Die E-Mail-Konfiguration wurde aktualisiert."



@@ 283,8 289,8 @@ msgid "Create Brand"
msgstr "Marke erstellen"

#: byceps/blueprints/admin/brand/templates/admin/brand/create_form.html:9
#: byceps/blueprints/admin/brand/templates/admin/brand/index.html:6
#: byceps/blueprints/admin/brand/templates/admin/brand/view.html:14
#: byceps/blueprints/admin/brand/templates/admin/brand/index.html:7
#: byceps/blueprints/admin/brand/templates/admin/brand/view.html:15
#: byceps/blueprints/admin/core/templates/layout/admin/_navigation_global.html:21
#: byceps/blueprints/admin/dashboard/templates/admin/dashboard/_brands.html:4
msgid "Brands"


@@ 294,17 300,17 @@ msgstr "Marken"
msgid "Update Email Configuration"
msgstr "E-Mail-Konfiguration bearbeiten"

#: byceps/blueprints/admin/brand/templates/admin/brand/index.html:17
#: byceps/blueprints/admin/brand/templates/admin/brand/index.html:18
msgid "Create brand"
msgstr "Marke erstellen"

#: byceps/blueprints/admin/brand/templates/admin/brand/index.html:27
#: byceps/blueprints/admin/brand/templates/admin/brand/view.html:40
#: byceps/blueprints/admin/brand/templates/admin/brand/index.html:28
#: byceps/blueprints/admin/brand/templates/admin/brand/view.html:46
#: byceps/blueprints/admin/snippet/forms.py:34
msgid "Name"
msgstr "Name"

#: byceps/blueprints/admin/brand/templates/admin/brand/index.html:28
#: byceps/blueprints/admin/brand/templates/admin/brand/index.html:29
#: byceps/blueprints/admin/core/templates/layout/admin/_navigation_brand.html:41
#: byceps/blueprints/admin/core/templates/layout/admin/_navigation_global.html:27
#: byceps/blueprints/admin/dashboard/templates/admin/dashboard/view_brand.html:21


@@ 312,13 318,13 @@ msgstr "Name"
msgid "Parties"
msgstr "Partys"

#: byceps/blueprints/admin/brand/templates/admin/brand/index.html:29
#: byceps/blueprints/admin/brand/templates/admin/brand/index.html:30
#: byceps/blueprints/admin/core/templates/layout/admin/_navigation_brand.html:47
#: byceps/blueprints/admin/dashboard/templates/admin/dashboard/view_brand.html:22
msgid "Organizers"
msgstr "Organisatoren"

#: byceps/blueprints/admin/brand/templates/admin/brand/index.html:49
#: byceps/blueprints/admin/brand/templates/admin/brand/index.html:55
msgid "No brands defined."
msgstr "Es sind keine Marken hinterlegt."



@@ 326,14 332,14 @@ msgstr "Es sind keine Marken hinterlegt."
msgid "Update Brand"
msgstr "Marke bearbeiten"

#: byceps/blueprints/admin/brand/templates/admin/brand/view.html:22
#: byceps/blueprints/admin/brand/templates/admin/brand/view.html:64
#: byceps/blueprints/admin/brand/templates/admin/brand/view.html:28
#: byceps/blueprints/admin/brand/templates/admin/brand/view.html:70
#: byceps/blueprints/admin/webhook/templates/admin/webhook/index.html:46
#: byceps/blueprints/admin/webhook/templates/admin/webhook/update_form.html:37
msgid "Update"
msgstr "Bearbeiten"

#: byceps/blueprints/admin/brand/templates/admin/brand/view.html:35
#: byceps/blueprints/admin/brand/templates/admin/brand/view.html:41
#: byceps/blueprints/admin/more/templates/admin/more/view_brand.html:17
#: byceps/blueprints/admin/more/templates/admin/more/view_party.html:17
#: byceps/blueprints/admin/more/templates/admin/more/view_site.html:17


@@ 341,19 347,19 @@ msgstr "Bearbeiten"
msgid "Settings"
msgstr "Einstellungen"

#: byceps/blueprints/admin/brand/templates/admin/brand/view.html:41
#: byceps/blueprints/admin/brand/templates/admin/brand/view.html:47
msgid "Value"
msgstr "Wert"

#: byceps/blueprints/admin/brand/templates/admin/brand/view.html:54
#: byceps/blueprints/admin/brand/templates/admin/brand/view.html:60
msgid "No settings defined for this brand."
msgstr "Für diese Marke sind keine Einstellungen hinterlegt."

#: byceps/blueprints/admin/brand/templates/admin/brand/view.html:59
#: byceps/blueprints/admin/brand/templates/admin/brand/view.html:65
msgid "Email Configuration"
msgstr "E-Mail-Konfiguration"

#: byceps/blueprints/admin/brand/templates/admin/brand/view.html:85
#: byceps/blueprints/admin/brand/templates/admin/brand/view.html:91
msgid "Not configured"
msgstr "Nicht konfiguriert"



@@ 942,11 948,6 @@ msgstr "Sitzplatzverwaltung geöffnet"
msgid "canceled"
msgstr "abgesagt"

#: byceps/blueprints/admin/party/forms.py:60
#: byceps/blueprints/admin/site/forms.py:90
msgid "archived"
msgstr "archiviert"

#: byceps/blueprints/admin/party/views.py:175
#, python-format
msgid "Party \"%(title)s\" has been created."


@@ 1541,7 1542,7 @@ msgid "Invalid confirmation word"
msgstr "Ungültiges Bestätigungswort"

#: byceps/blueprints/admin/user/views.py:194
#: byceps/blueprints/site/user/creation/views.py:118
#: byceps/blueprints/site/user/creation/views.py:119
#, python-format
msgid "User \"%(screen_name)s\" could not be created."
msgstr "Das Benutzerkonto für \"%(screen_name)s\" konnte nicht angelegt werden."


@@ 2409,7 2410,7 @@ msgstr "Bots sind nicht erlaubt."
msgid "Newsletter"
msgstr "Newsletter"

#: byceps/blueprints/site/user/creation/views.py:126
#: byceps/blueprints/site/user/creation/views.py:127
#, python-format
msgid ""
"User \"%(screen_name)s\" has been created. Before you can log in, please "


@@ 2419,7 2420,7 @@ msgstr ""
"damit anmelden kannst, muss zunächst der Link in der an die angegebene "
"Adresse verschickten E-Mail besucht werden."

#: byceps/blueprints/site/user/creation/views.py:148
#: byceps/blueprints/site/user/creation/views.py:149
msgid "User account creation is disabled."
msgstr "Das Erstellen von Benutzerkonten ist deaktiviert."



@@ 2505,7 2506,7 @@ msgstr "Deine Nachricht an %(screen_name)s wurde versendet."
msgid "Send"
msgstr "Senden"

#: byceps/services/news/html_service.py:76
#: byceps/services/news/html_service.py:77
msgid "Image credit"
msgstr "Bild"



@@ 2513,17 2514,17 @@ msgstr "Bild"
msgid "Not paid in time."
msgstr "Kein fristgerechter Geldeingang feststellbar."

#: byceps/services/shop/order/email/service.py:73
#: byceps/services/shop/order/email/service.py:74
#, python-format
msgid "Your order (%(order_number)s) has been received."
msgstr "Deine Bestellung (%(order_number)s) ist eingegangen."

#: byceps/services/shop/order/email/service.py:104
#: byceps/services/shop/order/email/service.py:105
#, python-format
msgid "Your order (%(order_number)s) has been canceled."
msgstr "Deine Bestellung (%(order_number)s) ist storniert worden."

#: byceps/services/shop/order/email/service.py:122
#: byceps/services/shop/order/email/service.py:123
#, python-format
msgid "Your order (%(order_number)s) has been paid."
msgstr "Deine Bestellung (%(order_number)s) ist bezahlt worden."