Skip to content

Commit

Permalink
Merge pull request cgwire#867 from EvanBldy/master
Browse files Browse the repository at this point in the history
various improvements
  • Loading branch information
EvanBldy authored Oct 8, 2024
2 parents e14d48e + 0e4ef5d commit 96a4dae
Show file tree
Hide file tree
Showing 20 changed files with 97 additions and 74 deletions.
12 changes: 6 additions & 6 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ install_requires =
flask-fs2[swift, s3]==0.7.27
flask-jwt-extended==4.6.0
flask-migrate==4.0.7
flask-socketio==5.4.0
flask-socketio==5.4.1
flask==3.0.3
gazu==0.10.15
gevent-websocket==0.10.1
Expand All @@ -56,7 +56,7 @@ install_requires =
matterhook==0.2
meilisearch==0.31.5
numpy==2.0.1; python_version == '3.9'
numpy==2.1.1; python_version >= '3.10'
numpy==2.1.2; python_version >= '3.10'
opencv-python==4.10.0.84
OpenTimelineIO==0.17.0
OpenTimelineIO-Plugins==0.17.0
Expand All @@ -70,7 +70,7 @@ install_requires =
python-slugify==8.0.4
python-socketio==5.11.4
pytz==2024.2
redis==5.1.0
redis==5.1.1
requests==2.32.3
rq==1.16.2
slackclient==2.9.4
Expand Down Expand Up @@ -103,12 +103,12 @@ test =
monitoring =
prometheus-flask-exporter==0.23.1
pygelf==0.4.2
sentry-sdk==2.14.0
sentry-sdk==2.16.0

lint =
autoflake==2.3.1
black==24.8.0
pre-commit==3.8.0; python_version >= '3.9'
black==24.10.0
pre-commit==4.0.0

[options.entry_points]
console_scripts =
Expand Down
8 changes: 2 additions & 6 deletions tests/services/test_names_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,8 @@ def setUp(self):
self.shot_task = self.generate_fixture_shot_task().serialize()

def test_get_full_entity_name(self):
(asset_name, episode_id) = names_service.get_full_entity_name(
self.asset.id
)
(shot_name, episode_id) = names_service.get_full_entity_name(
self.shot.id
)
asset_name, _, _ = names_service.get_full_entity_name(self.asset.id)
shot_name, _, _ = names_service.get_full_entity_name(self.shot.id)
self.assertEqual(asset_name, "Props / Tree")
self.assertEqual(shot_name, "E01 / S01 / P01")

Expand Down
4 changes: 3 additions & 1 deletion zou/app/blueprints/chats/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ def post(self, entity_id):

chat = chats_service.get_chat(entity_id)
if person["id"] not in chat["participants"]:
raise WrongParameterException("You are not a participant of this chat")
raise WrongParameterException(
"You are not a participant of this chat"
)

return (
chats_service.create_chat_message(
Expand Down
8 changes: 6 additions & 2 deletions zou/app/blueprints/crud/day_off.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ def check_creation_integrity(self, data):
if time_spents_service.get_day_offs_between(
data["date"], data["end_date"], data["person_id"]
):
raise WrongParameterException("Day off already exists for this period")
raise WrongParameterException(
"Day off already exists for this period"
)
return data

def post_creation(self, instance):
Expand Down Expand Up @@ -67,5 +69,7 @@ def pre_update(self, instance_dict, data):
data.get("person_id", instance_dict["person_id"]),
exclude_id=instance_dict["id"],
):
raise WrongParameterException("Day off already exists for this period")
raise WrongParameterException(
"Day off already exists for this period"
)
return data
9 changes: 3 additions & 6 deletions zou/app/blueprints/crud/entity_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from zou.app.services.exception import WrongParameterException



class EntityTypesResource(BaseModelsResource):
def __init__(self):
BaseModelsResource.__init__(self, EntityType)
Expand All @@ -32,11 +31,9 @@ def post_creation(self, instance):
return instance.serialize(relations=True)

def check_creation_integrity(self, data):
entity_type = (
EntityType.query
.filter(EntityType.name.ilike(data.get("name", "")))
.first()
)
entity_type = EntityType.query.filter(
EntityType.name.ilike(data.get("name", ""))
).first()
if entity_type is not None:
raise WrongParameterException(
"Entity type with this name already exists"
Expand Down
8 changes: 6 additions & 2 deletions zou/app/blueprints/crud/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ def update_data(self, data):
or data["preview_background_file_id"]
not in data["preview_background_files_ids"]
):
raise WrongParameterException("Invalid preview_background_file_id")
raise WrongParameterException(
"Invalid preview_background_file_id"
)
return data

def post_creation(self, project):
Expand Down Expand Up @@ -131,7 +133,9 @@ def pre_update(self, project_dict, data):
data["preview_background_file_id"]
not in preview_background_files_ids
):
raise WrongParameterException("Invalid preview_background_file_id")
raise WrongParameterException(
"Invalid preview_background_file_id"
)

return data

Expand Down
4 changes: 3 additions & 1 deletion zou/app/blueprints/crud/schedule_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ def check_creation_integrity(self, data):
object_id=data.get("object_id", None),
)
if schedule_item is not None:
raise WrongParameterException("A similar schedule item already exists")
raise WrongParameterException(
"A similar schedule item already exists"
)
return schedule_item


Expand Down
2 changes: 1 addition & 1 deletion zou/app/blueprints/export/csv/playlists.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def build_headers(self, playlist, project, episode=None):

def build_row(self, shot):
entity = entities_service.get_entity(shot["entity_id"])
name, _ = names_service.get_full_entity_name(shot["entity_id"])
name, _, _ = names_service.get_full_entity_name(shot["entity_id"])
preview_file = files_service.get_preview_file(shot["preview_file_id"])
task = tasks_service.get_task(preview_file["task_id"])
task_type = self.task_type_map[task["task_type_id"]]
Expand Down
2 changes: 1 addition & 1 deletion zou/app/blueprints/export/csv/time_spents.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def build_row(self, time_spent_row):
person_last_name,
) = time_spent_row
if entity_type_name == "Shot":
entity_name, _ = names_service.get_full_entity_name(entity_id)
entity_name, _, _ = names_service.get_full_entity_name(entity_id)

date = ""
if time_spent.date is not None:
Expand Down
3 changes: 1 addition & 2 deletions zou/app/blueprints/user/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -865,14 +865,13 @@ def get(self):
)
return notifications


def get_arguments(self):
return (
self.get_text_parameter("after"),
self.get_text_parameter("before"),
self.get_text_parameter("task_type_id"),
self.get_text_parameter("task_status_id"),
self.get_text_parameter("type")
self.get_text_parameter("type"),
)


Expand Down
4 changes: 2 additions & 2 deletions zou/app/models/subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ class Subscription(db.Model, BaseMixin, SerializerMixin):

entity_id = db.Column(
UUIDType(binary=False), db.ForeignKey("entity.id"), index=True
) # Deprecated
) # Deprecated
task_type_id = db.Column(
UUIDType(binary=False), db.ForeignKey("task_type.id"), index=True
) # Deprecated
) # Deprecated

__table_args__ = (
db.UniqueConstraint(
Expand Down
9 changes: 4 additions & 5 deletions zou/app/models/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@ class Task(db.Model, BaseMixin, SerializerMixin):
description = db.Column(db.Text())

priority = db.Column(db.Integer, default=0)
difficulty = db.Column(
db.Integer,
db.CheckConstraint('difficulty > 0 AND difficulty < 6'),
default=3,
)
difficulty = db.Column(db.Integer, default=3, nullable=False)
duration = db.Column(db.Float, default=0)
estimation = db.Column(db.Float, default=0)
completion_rate = db.Column(db.Integer, default=0)
Expand Down Expand Up @@ -75,6 +71,9 @@ class Task(db.Model, BaseMixin, SerializerMixin):
db.UniqueConstraint(
"name", "project_id", "task_type_id", "entity_id", name="task_uc"
),
db.CheckConstraint(
"difficulty > 0 AND difficulty < 6", name="check_difficulty"
),
)

def assignees_as_string(self):
Expand Down
6 changes: 3 additions & 3 deletions zou/app/services/assets_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ def get_assets(criterions={}, is_admin=False):

if "is_shared" in criterions:
if not is_admin:
query = (
query.join(Project).filter(user_service.build_team_filter())
query = query.join(Project).filter(
user_service.build_team_filter()
)

if episode_id is not None:
Expand Down Expand Up @@ -725,7 +725,7 @@ def set_shared_assets(
project_id=None,
asset_type_id=None,
asset_ids=None,
with_events=False
with_events=False,
):
"""
Set all assets of a project to is_shared=True or False.
Expand Down
2 changes: 1 addition & 1 deletion zou/app/services/chats_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def get_chats_for_person(person_id):
result = []
for chat_model, project_id, preview_file_id in chats:
chat = chat_model.present()
chat["entity_name"], _ = names_service.get_full_entity_name(
chat["entity_name"], _, _ = names_service.get_full_entity_name(
chat["object_id"]
)
chat["project_id"] = project_id
Expand Down
2 changes: 1 addition & 1 deletion zou/app/services/emails_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ def get_task_descriptors(person_id, task):
project = projects_service.get_project(task["project_id"])
task_type = tasks_service.get_task_type(task["task_type_id"])
entity = entities_service.get_entity(task["entity_id"])
(entity_name, episode_id) = names_service.get_full_entity_name(
entity_name, episode_id, _ = names_service.get_full_entity_name(
entity["id"]
)

Expand Down
2 changes: 1 addition & 1 deletion zou/app/services/news_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def get_last_news_for_project(
preview_file_annotations,
entity_preview_file_id,
) in news_list:
(full_entity_name, episode_id) = names_service.get_full_entity_name(
full_entity_name, episode_id, _ = names_service.get_full_entity_name(
task_entity_id
)

Expand Down
2 changes: 1 addition & 1 deletion zou/app/services/preview_files_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ def get_running_preview_files():
result = preview_file.serialize()
result["project_id"] = fields.serialize_value(project_id)
result["task_type_id"] = fields.serialize_value(task_type_id)
(result["full_entity_name"], _) = names_service.get_full_entity_name(
result["full_entity_name"], _, _ = names_service.get_full_entity_name(
entity_id
)
results.append(result)
Expand Down
6 changes: 3 additions & 3 deletions zou/app/services/shots_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -1481,7 +1481,7 @@ def get_weighted_quota_shots_between(
for entity, task_duration, duration in query_shots:
shot = entity.serialize()
if shot["id"] not in already_listed:
full_name, _ = names_service.get_full_entity_name(shot["id"])
full_name, _, _ = names_service.get_full_entity_name(shot["id"])
shot["full_name"] = full_name
shot["weight"] = round(duration / task_duration, 2) or 0
shots.append(shot)
Expand Down Expand Up @@ -1528,7 +1528,7 @@ def get_weighted_quota_shots_between(
business_days = (
date_helpers.get_business_days(task_start, task_end) + 1
)
full_name, _ = names_service.get_full_entity_name(shot["id"])
full_name, _, _ = names_service.get_full_entity_name(shot["id"])
shot["full_name"] = full_name
multiplicator = 1
if task_start >= start and task_end <= end:
Expand Down Expand Up @@ -1586,7 +1586,7 @@ def get_raw_quota_shots_between(

for entity in query_shots:
shot = entity.serialize()
full_name, _ = names_service.get_full_entity_name(shot["id"])
full_name, _, _ = names_service.get_full_entity_name(shot["id"])
shot["full_name"] = full_name
shot["weight"] = 1
shots.append(shot)
Expand Down
16 changes: 8 additions & 8 deletions zou/app/services/user_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -1210,6 +1210,7 @@ def get_unread_notifications_count(notification_id=None):

from sqlalchemy import and_, func


def get_last_notifications(
notification_id=None,
after=None,
Expand All @@ -1233,11 +1234,12 @@ def get_last_notifications(
.join(Author, Author.id == Notification.author_id)
.join(Task, Task.id == Notification.task_id)
.join(Project, Project.id == Task.project_id)
.outerjoin(Subscription,
.outerjoin(
Subscription,
and_(
Subscription.task_id == Task.id,
Subscription.person_id == current_user["id"]
)
Subscription.person_id == current_user["id"],
),
)
.outerjoin(Comment, Comment.id == Notification.comment_id)
.add_columns(
Expand Down Expand Up @@ -1303,11 +1305,9 @@ def get_last_notifications(
subscription_id,
role,
) in notifications:
(
full_entity_name,
episode_id,
entity_preview_file_id
) = names_service.get_full_entity_name(task_entity_id)
(full_entity_name, episode_id, entity_preview_file_id) = (
names_service.get_full_entity_name(task_entity_id)
)
preview_file_id = None
mentions = []
department_mentions = []
Expand Down
Loading

0 comments on commit 96a4dae

Please sign in to comment.