Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

various improvements #911

Merged
merged 4 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ install_requires =
flask-migrate==4.1.0
flask-socketio==5.5.1
flask==3.1.0
gazu==0.10.22
gazu==0.10.23
gevent-websocket==0.10.1
gevent==24.11.1
gunicorn==23.0.0
Expand Down Expand Up @@ -105,7 +105,7 @@ test =
monitoring =
prometheus-flask-exporter==0.23.1
pygelf==0.4.2
sentry-sdk==2.19.2
sentry-sdk==2.20.0

lint =
autoflake==2.3.1
Expand Down
9 changes: 9 additions & 0 deletions zou/app/blueprints/projects/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
)
from zou.app.utils import permissions
from zou.app.services.exception import WrongParameterException
from zou.app.models.metadata_descriptor import METADATA_DESCRIPTOR_TYPES


class OpenProjectsResource(Resource, ArgsMixin):
Expand Down Expand Up @@ -715,6 +716,10 @@ def post(self, project_id):
if len(args["name"]) == 0:
raise WrongParameterException("Name cannot be empty.")

types = [type_name for type_name, _ in METADATA_DESCRIPTOR_TYPES]
if args["data_type"] not in types:
raise WrongParameterException("Invalid data_type")

return (
projects_service.add_metadata_descriptor(
project_id,
Expand Down Expand Up @@ -828,6 +833,10 @@ def put(self, project_id, descriptor_id):
if len(args["name"]) == 0:
raise WrongParameterException("Name cannot be empty.")

types = [type_name for type_name, _ in METADATA_DESCRIPTOR_TYPES]
if args["data_type"] not in types:
raise WrongParameterException("Invalid data_type")

args["for_client"] = args["for_client"] == "True"

return projects_service.update_metadata_descriptor(descriptor_id, args)
Expand Down
10 changes: 10 additions & 0 deletions zou/app/models/person.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,21 @@ class DepartmentLink(db.Model):
UUIDType(binary=False),
db.ForeignKey("person.id"),
primary_key=True,
index=True,
)
department_id = db.Column(
UUIDType(binary=False),
db.ForeignKey("department.id"),
primary_key=True,
index=True,
)

__table_args__ = (
db.UniqueConstraint(
"person_id",
"department_id",
name="department_link_uc",
),
)


Expand Down
2 changes: 1 addition & 1 deletion zou/app/services/user_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -1424,7 +1424,7 @@ def get_last_notifications(
)
reply_mentions = reply.get("mentions", []) or []
reply_department_mentions = (
reply.get("departement_mentions", []) or []
reply.get("department_mentions", []) or []
)
if reply is not None:
reply_text = reply["text"]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
"""For DepartmentLink index person_id / department_id

Revision ID: 539a3a00c417
Revises: 9d3bb33c6fc6
Create Date: 2025-01-14 12:19:52.699322

"""

from alembic import op


# revision identifiers, used by Alembic.
revision = "539a3a00c417"
down_revision = "9d3bb33c6fc6"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("department_link", schema=None) as batch_op:
batch_op.create_unique_constraint(
"department_link_uc", ["person_id", "department_id"]
)
batch_op.create_index(
batch_op.f("ix_department_link_department_id"),
["department_id"],
unique=False,
)
batch_op.create_index(
batch_op.f("ix_department_link_person_id"),
["person_id"],
unique=False,
)
batch_op.create_primary_key(
"department_link_pkey", ["person_id", "department_id"]
)

# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("department_link", schema=None) as batch_op:
batch_op.drop_index(batch_op.f("ix_department_link_person_id"))
batch_op.drop_index(batch_op.f("ix_department_link_department_id"))
batch_op.drop_constraint("department_link_uc", type_="unique")
batch_op.drop_constraint("department_link_pkey", type_="primary")

# ### end Alembic commands ###
Loading