Skip to content

Commit

Permalink
Merge pull request cgwire#866 from frankrousseau/master
Browse files Browse the repository at this point in the history
Various improvements
  • Loading branch information
EvanBldy authored Oct 8, 2024
2 parents 9aca5a5 + d1a766a commit e14d48e
Show file tree
Hide file tree
Showing 13 changed files with 191 additions and 21 deletions.
3 changes: 3 additions & 0 deletions zou/app/blueprints/previews/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"glb",
"gltf",
"hip",
"kra",
"ma",
"mb",
"mp3",
Expand All @@ -73,6 +74,8 @@
"psd",
"psb",
"rar",
"sai",
"sai2",
"sbbkp",
"svg",
"swf",
Expand Down
5 changes: 5 additions & 0 deletions zou/app/blueprints/user/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
FilterGroupResource,
FilterGroupsResource,
DesktopLoginLogsResource,
MarkAllNotificationsAsReadResource,
NotificationsResource,
NotificationResource,
HasTaskSubscribedResource,
Expand Down Expand Up @@ -108,6 +109,10 @@
"/actions/user/sequences/<sequence_id>/task-types/<task_type_id>/unsubscribe",
SequenceUnsubscribeResource,
),
(
"/actions/user/notifications/mark-all-as-read",
MarkAllNotificationsAsReadResource,
),
]

blueprint = Blueprint("user", "user")
Expand Down
57 changes: 51 additions & 6 deletions zou/app/blueprints/user/resources.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from flask import abort
from flask import abort, request
from flask_restful import Resource

from zou.app.mixin import ArgsMixin
Expand Down Expand Up @@ -593,7 +593,6 @@ def put(self, filter_id):
("project_id", None, None),
]
)

data = self.clear_empty_fields(
data, ignored_fields=["search_filter_group_id"]
)
Expand Down Expand Up @@ -848,26 +847,36 @@ def get(self):
task_status_id,
notification_type,
) = self.get_arguments()

read = None
if request.args.get("read", None) is not None:
read = self.get_bool_parameter("read")
watching = None
if request.args.get("watching", None) is not None:
watching = self.get_bool_parameter("watching")
print("watching", watching)
notifications = user_service.get_last_notifications(
before=before,
task_type_id=task_type_id,
task_status_id=task_status_id,
notification_type=notification_type,
read=read,
watching=watching,
)
user_service.mark_notifications_as_read()
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")
)


class NotificationResource(Resource):
class NotificationResource(Resource, ArgsMixin):
"""
Return notification matching given id, only if it's a notification that
belongs to current user.
Expand All @@ -894,6 +903,42 @@ def get(self, notification_id):
"""
return user_service.get_notification(notification_id)

def put(self, notification_id):
"""
Change notification read status.
---
tags:
- User
parameters:
- in: path
name: notification_id
required: True
type: string
format: UUID
x-example: a24a6ea4-ce75-4665-a070-57453082c25
responses:
200:
description: Notification
"""
data = self.get_args([("read", None, False, bool)])
return user_service.update_notification(notification_id, data["read"])


class MarkAllNotificationsAsReadResource(Resource):

def post(self):
"""
Mark all notifications as read for the current user.
---
tags:
- User
responses:
200:
description: All notifications marked as read
"""
user_service.mark_notifications_as_read()
return {"success": True}


class HasTaskSubscribedResource(Resource):
"""
Expand All @@ -905,7 +950,7 @@ def get(self, task_id):
Return true if current user has subscribed to given task.
---
tags:
- User
- User
parameters:
- in: path
name: task_id
Expand Down
3 changes: 3 additions & 0 deletions zou/app/models/organisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class Organisation(db.Model, BaseMixin, SerializerMixin):
chat_token_slack = db.Column(db.String(80), default="")
chat_webhook_mattermost = db.Column(db.String(80), default="")
chat_token_discord = db.Column(db.String(80), default="")
dark_theme_by_default = db.Column(db.Boolean(), default=False)
format_duration_in_hours = db.Column(db.Boolean(), default=False)

def present(self):
return fields.serialize_dict(
Expand All @@ -33,6 +35,7 @@ def present(self):
"hd_by_default": self.hd_by_default,
"use_original_file_name": self.use_original_file_name,
"timesheets_locked": self.timesheets_locked,
"dark_theme_by_default": self.dark_theme_by_default,
"format_duration_in_hours": self.format_duration_in_hours,
"updated_at": self.updated_at,
"created_at": self.created_at,
Expand Down
3 changes: 3 additions & 0 deletions zou/app/models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ class Project(db.Model, BaseMixin, SerializerMixin):
is_preview_download_allowed = db.Column(db.Boolean(), default=False)
is_set_preview_automated = db.Column(db.Boolean(), default=False)
homepage = db.Column(db.String(80), default="assets")
is_publish_default_for_artists = db.Column(db.Boolean(), default=False)
hd_bitrate_compression = db.Column(db.Integer, default=28)
ld_bitrate_compression = db.Column(db.Integer, default=6)

project_status_id = db.Column(
UUIDType(binary=False), db.ForeignKey("project_status.id"), index=True
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
task_type_id = db.Column(
UUIDType(binary=False), db.ForeignKey("task_type.id"), index=True
)
) # Deprecated

__table_args__ = (
db.UniqueConstraint(
Expand Down
5 changes: 5 additions & 0 deletions zou/app/models/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ 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,
)
duration = db.Column(db.Float, default=0)
estimation = db.Column(db.Float, default=0)
completion_rate = db.Column(db.Integer, default=0)
Expand Down
5 changes: 4 additions & 1 deletion zou/app/services/assets_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def get_assets(criterions={}, is_admin=False):
result += [a for a in query.all() if a.source_id != episode_id]
else:
result = query.all()
return EntityType.serialize_list(result, obj_type="Asset")
return Entity.serialize_list(result, obj_type="Asset")


def get_all_raw_assets():
Expand Down Expand Up @@ -202,6 +202,7 @@ def get_assets_and_tasks(criterions={}, page=1, with_episode_ids=False):
Task.due_date,
Task.done_date,
Task.last_comment_date,
Task.difficulty,
assignees_table.columns.person,
).order_by(EntityType.name, Entity.name)

Expand Down Expand Up @@ -281,6 +282,7 @@ def get_assets_and_tasks(criterions={}, page=1, with_episode_ids=False):
task_due_date,
task_done_date,
task_last_comment_date,
task_difficulty,
person_id,
) in query_result:
if asset.source_id is None:
Expand Down Expand Up @@ -338,6 +340,7 @@ def get_assets_and_tasks(criterions={}, page=1, with_episode_ids=False):
),
"retake_count": task_retake_count,
"start_date": fields.serialize_value(task_start_date),
"difficulty": task_difficulty,
"task_status_id": str(task_status_id),
"task_type_id": str(task_type_id),
"assignees": [],
Expand Down
3 changes: 3 additions & 0 deletions zou/app/services/entities_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ def get_entities_and_tasks(criterions={}):
Task.due_date,
Task.done_date,
Task.last_comment_date,
Task.difficulty,
assignees_table.columns.person,
)
)
Expand Down Expand Up @@ -272,6 +273,7 @@ def get_entities_and_tasks(criterions={}):
task_due_date,
task_done_date,
task_last_comment_date,
task_difficulty,
person_id,
) in query.all():
entity_id = str(entity.id)
Expand Down Expand Up @@ -315,6 +317,7 @@ def get_entities_and_tasks(criterions={}):
"real_start_date": task_real_start_date,
"retake_count": task_retake_count,
"start_date": task_start_date,
"difficulty": task_difficulty,
"task_status_id": str(task_status_id),
"task_type_id": str(task_type_id),
"assignees": [],
Expand Down
4 changes: 2 additions & 2 deletions zou/app/services/names_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def get_full_entity_name(entity_id):
asset_type = entities_service.get_entity_type(entity["entity_type_id"])
episode_id = entity["source_id"]
name = "%s / %s" % (asset_type["name"], entity["name"])
return (name, episode_id)
return (name, episode_id, entity["preview_file_id"])


def get_preview_file_name(preview_file_id):
Expand All @@ -66,7 +66,7 @@ def get_preview_file_name(preview_file_id):
task = tasks_service.get_task(preview_file["task_id"])
task_type = tasks_service.get_task_type(task["task_type_id"])
project = projects_service.get_project(task["project_id"])
(entity_name, _) = get_full_entity_name(task["entity_id"])
(entity_name, _, _) = get_full_entity_name(task["entity_id"])

if (
organisation["use_original_file_name"]
Expand Down
3 changes: 3 additions & 0 deletions zou/app/services/shots_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ def get_shots_and_tasks(criterions={}):
Task.done_date,
Task.last_comment_date,
Task.nb_assets_ready,
Task.difficulty,
assignees_table.columns.person,
Project.id,
Project.name,
Expand Down Expand Up @@ -304,6 +305,7 @@ def get_shots_and_tasks(criterions={}):
task_done_date,
task_last_comment_date,
task_nb_assets_ready,
task_difficulty,
person_id,
project_id,
project_name,
Expand Down Expand Up @@ -367,6 +369,7 @@ def get_shots_and_tasks(criterions={}):
"real_start_date": task_real_start_date,
"retake_count": task_retake_count,
"start_date": task_start_date,
"difficulty": task_difficulty,
"task_status_id": task_status_id,
"task_type_id": task_type_id,
"assignees": [],
Expand Down
Loading

0 comments on commit e14d48e

Please sign in to comment.