Skip to content

Commit

Permalink
Remove picto liste
Browse files Browse the repository at this point in the history
  • Loading branch information
amandine-sahl committed Jul 31, 2023
1 parent 95429b9 commit 804d896
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 27 deletions.
25 changes: 1 addition & 24 deletions apptax/admin/admin_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class BibListesView(FlaskAdminProtectedMixin, ModelView):

can_view_details = True

column_list = ("regne", "group2_inpn", "picto", "code_liste", "nom_liste", "nb_taxons")
column_list = ("regne", "group2_inpn", "code_liste", "nom_liste", "nb_taxons")

column_labels = dict(nb_taxons="Nb taxons")

Expand All @@ -154,29 +154,6 @@ class BibListesView(FlaskAdminProtectedMixin, ModelView):
EndpointLinkRowAction("fa fa-download", ".import_cd_nom_view", "Populate list"),
]

def get_picto_list():
pictos = os.listdir(os.path.join(adresses.static_folder, "images", "pictos"))
return [(p, p) for p in pictos]

form_extra_fields = {"picto": Select2Field("Picto", choices=get_picto_list(), default="")}

def _list_picto(view, context, model, name):
path = None
if model.picto:
path = url_for(
".static",
filename=f"images/pictos/{model.picto}",
_external=True,
)
elif model.url:
path = model.url

if not path:
return
return markupsafe.Markup(f"<img src='{path}'>")

column_formatters = {"picto": _list_picto}

def render(self, template, **kwargs):
self.extra_js = [
url_for("configs.get_config"),
Expand Down
27 changes: 27 additions & 0 deletions apptax/migrations/versions/5cef20a05a20_remove_picto.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""remove picto
Revision ID: 5cef20a05a20
Revises: 1cf2cdc94f9b
Create Date: 2023-07-31 16:15:29.608981
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "5cef20a05a20"
down_revision = "1cf2cdc94f9b"
branch_labels = None
depends_on = None
from sqlalchemy import Column, String


def upgrade():
op.drop_column(table_name="bib_listes", column_name="picto", schema="taxonomie")


def downgrade():
op.add_column(
table_name="bib_listes", column=sa.Column("picto", String(250)), schema="taxonomie"
)
1 change: 0 additions & 1 deletion apptax/taxonomie/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ class BibListes(db.Model):
code_liste = db.Column(db.Unicode)
nom_liste = db.Column(db.Unicode)
desc_liste = db.Column(db.Text)
picto = db.Column(db.Unicode)
v_regne = db.Column(
db.Unicode,
ForeignKey(VMRegne.regne),
Expand Down
2 changes: 1 addition & 1 deletion apptax/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"nom_liste": "test",
"code_liste": "test code",
"desc_liste": "test desc",
"picto": "mousse.gif",
}

form_attributs = {
Expand Down Expand Up @@ -84,6 +83,7 @@ def test_insert_taxref(self, users, attribut_example):
data=form_taxref,
content_type="multipart/form-data",
)

assert req.status_code == 302

tax = db.session.query(Taxref).filter_by(cd_nom=117526).scalar()
Expand Down
1 change: 0 additions & 1 deletion apptax/tests/test_biblistes.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def test_cor_nom_liste(self, noms_example):
"code_liste": str,
"nom_liste": str,
"desc_liste": str,
"picto": str,
"regne": Or(str, None),
"group2_inpn": Or(str, None),
"nb_taxons": int,
Expand Down

0 comments on commit 804d896

Please sign in to comment.