diff --git a/forms/admin_unit.py b/forms/admin_unit.py index 2333188..8b7cbf4 100644 --- a/forms/admin_unit.py +++ b/forms/admin_unit.py @@ -4,6 +4,7 @@ from flask_wtf.file import FileField, FileAllowed from wtforms import StringField, SubmitField, DecimalField, TextAreaField, FormField, SelectField from wtforms.fields.html5 import EmailField, TelField, URLField from wtforms.validators import DataRequired, Optional, Regexp +from wtforms.widgets.html5 import ColorInput import decimal from models import Location, Image from .common import FileImageForm @@ -38,4 +39,11 @@ class CreateAdminUnitForm(BaseAdminUnitForm): submit = SubmitField(lazy_gettext("Create admin unit")) class UpdateAdminUnitForm(BaseAdminUnitForm): + submit = SubmitField(lazy_gettext("Update settings")) + +class UpdateAdminUnitWidgetForm(FlaskForm): + widget_font = StringField(lazy_gettext('Font'), validators=[Optional()]) + widget_background_color = StringField(lazy_gettext('Background Color'), default='#ffffff', widget=ColorInput(), validators=[Optional()]) + widget_primary_color = StringField(lazy_gettext('Primary Color'), default='#007bff', widget=ColorInput(), validators=[Optional()]) + widget_link_color = StringField(lazy_gettext('Link Color'), default='#007bff', widget=ColorInput(), validators=[Optional()]) submit = SubmitField(lazy_gettext("Update settings")) \ No newline at end of file diff --git a/migrations/versions/27da3ceea723_.py b/migrations/versions/27da3ceea723_.py new file mode 100644 index 0000000..a8e85a6 --- /dev/null +++ b/migrations/versions/27da3ceea723_.py @@ -0,0 +1,46 @@ +"""empty message + +Revision ID: 27da3ceea723 +Revises: 00daa8c472ba +Create Date: 2020-11-08 16:14:01.866196 + +""" +from alembic import op +import sqlalchemy as sa +import sqlalchemy_utils +import db + + +# revision identifiers, used by Alembic. +revision = '27da3ceea723' +down_revision = '00daa8c472ba' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + #op.drop_table('spatial_ref_sys') + op.add_column('adminunit', sa.Column('widget_background_color', sqlalchemy_utils.types.color.ColorType(length=20), nullable=True)) + op.add_column('adminunit', sa.Column('widget_font', sa.Unicode(length=255), nullable=True)) + op.add_column('adminunit', sa.Column('widget_link_color', sqlalchemy_utils.types.color.ColorType(length=20), nullable=True)) + op.add_column('adminunit', sa.Column('widget_primary_color', sqlalchemy_utils.types.color.ColorType(length=20), nullable=True)) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column('adminunit', 'widget_primary_color') + op.drop_column('adminunit', 'widget_link_color') + op.drop_column('adminunit', 'widget_font') + op.drop_column('adminunit', 'widget_background_color') + op.create_table('spatial_ref_sys', + sa.Column('srid', sa.INTEGER(), autoincrement=False, nullable=False), + sa.Column('auth_name', sa.VARCHAR(length=256), autoincrement=False, nullable=True), + sa.Column('auth_srid', sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column('srtext', sa.VARCHAR(length=2048), autoincrement=False, nullable=True), + sa.Column('proj4text', sa.VARCHAR(length=2048), autoincrement=False, nullable=True), + sa.CheckConstraint('(srid > 0) AND (srid <= 998999)', name='spatial_ref_sys_srid_check'), + sa.PrimaryKeyConstraint('srid', name='spatial_ref_sys_pkey') + ) + # ### end Alembic commands ### diff --git a/models.py b/models.py index b0bb6fe..3d2e71d 100644 --- a/models.py +++ b/models.py @@ -6,6 +6,7 @@ from sqlalchemy.schema import CheckConstraint from sqlalchemy.types import TypeDecorator from sqlalchemy.event import listens_for from sqlalchemy import UniqueConstraint, Boolean, DateTime, Column, Integer, String, ForeignKey, Unicode, UnicodeText, Numeric, LargeBinary +from sqlalchemy_utils import ColorType from flask_security import UserMixin, RoleMixin from flask_dance.consumer.storage.sqla import OAuthConsumerMixin from enum import IntEnum @@ -130,6 +131,10 @@ class AdminUnit(db.Model, TrackableMixin): email = Column(Unicode(255)) phone = Column(Unicode(255)) fax = Column(Unicode(255)) + widget_font = Column(Unicode(255)) + widget_background_color = Column(ColorType) + widget_primary_color = Column(ColorType) + widget_link_color = Column(ColorType) @listens_for(AdminUnit, 'before_insert') @listens_for(AdminUnit, 'before_update') @@ -426,4 +431,4 @@ class FeaturedEventRejectionReason(IntEnum): untrustworthy = 2 illegal = 3 irrelevant = 4 -# Deprecated end \ No newline at end of file +# Deprecated end diff --git a/requirements.txt b/requirements.txt index 7a2a0bb..fa1d76c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,6 +7,7 @@ certifi==2020.6.20 cffi==1.14.0 chardet==3.0.4 click==7.1.2 +colour==0.1.5 dnspython==1.16.0 dominate==2.5.1 email-validator==1.1.1 diff --git a/static/widget.css b/static/widget.css index 44f007f..2cc045d 100644 --- a/static/widget.css +++ b/static/widget.css @@ -1,34 +1,12 @@ -body { - background-color:#eceef0; - font-family: Verdana; - color: #3c444b; -} - -.btn-primary { - background-color: #B09641; - color: black; - border-color: #B09641; -} - -.btn-primary:hover { - background-color: #B09641; - color: black; - border-color: #B09641; -} - .card { background-color: transparent; } -.card-title, .page-link, .page-link:hover, a, a:hover { - color: #7B2424; -} - .wizard > .steps .disabled a, .wizard > .steps .disabled a:hover, .wizard > .steps .disabled a:active { - background: #aaa; + background-color: #aaa; color: #aaa; cursor: default; } @@ -37,7 +15,7 @@ body { .wizard > .steps .current a:hover, .wizard > .steps .current a:active { - background: #B09641; + background-color: #17a2b8; color: #fff; cursor: default; } @@ -46,7 +24,7 @@ body { .wizard > .steps .done a:hover, .wizard > .steps .done a:active { - background: #B09641; + background-color: #17a2b8; color: #fff; } @@ -54,7 +32,7 @@ body { .wizard > .actions a:hover, .wizard > .actions a:active { - background: #B09641; + background-color: #17a2b8; color: #fff; display: block; padding: 0.5em 1em; diff --git a/templates/_macros.html b/templates/_macros.html index de54f85..89df2a4 100644 --- a/templates/_macros.html +++ b/templates/_macros.html @@ -992,3 +992,51 @@ if (URL) { {% endmacro %} +{% macro render_widget_styles(styles) %} + +{% endmacro %} \ No newline at end of file diff --git a/templates/example.html b/templates/example.html index 6538595..793d05a 100644 --- a/templates/example.html +++ b/templates/example.html @@ -7,8 +7,8 @@ oveda - Terminkalender für Goslar und Hahnenklee