Skip to content

Commit

Permalink
[qa] black
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanBldy committed Oct 8, 2024
1 parent 666071f commit a71be46
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 49 deletions.
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
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
2 changes: 1 addition & 1 deletion zou/app/models/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Task(db.Model, BaseMixin, SerializerMixin):
priority = db.Column(db.Integer, default=0)
difficulty = db.Column(
db.Integer,
db.CheckConstraint('difficulty > 0 AND difficulty < 6'),
db.CheckConstraint("difficulty > 0 AND difficulty < 6"),
default=3,
)
duration = db.Column(db.Float, default=0)
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
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
56 changes: 35 additions & 21 deletions zou/migrations/versions/8e67c183bed7_add_preference_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,61 @@
Create Date: 2024-09-26 10:48:45.678791
"""

from alembic import op
import sqlalchemy as sa
import sqlalchemy_utils


# revision identifiers, used by Alembic.
revision = '8e67c183bed7'
down_revision = '59a7445a966c'
revision = "8e67c183bed7"
down_revision = "59a7445a966c"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('organisation', schema=None) as batch_op:
batch_op.add_column(sa.Column('dark_theme_by_default', sa.Boolean(), nullable=True))
batch_op.add_column(sa.Column('format_duration_in_hours', sa.Boolean(), nullable=True))
with op.batch_alter_table("organisation", schema=None) as batch_op:
batch_op.add_column(
sa.Column("dark_theme_by_default", sa.Boolean(), nullable=True)
)
batch_op.add_column(
sa.Column("format_duration_in_hours", sa.Boolean(), nullable=True)
)

with op.batch_alter_table('project', schema=None) as batch_op:
batch_op.add_column(sa.Column('is_publish_default_for_artists', sa.Boolean(), nullable=True))
batch_op.add_column(sa.Column('hd_bitrate_compression', sa.Integer(), nullable=True))
batch_op.add_column(sa.Column('ld_bitrate_compression', sa.Integer(), nullable=True))
with op.batch_alter_table("project", schema=None) as batch_op:
batch_op.add_column(
sa.Column(
"is_publish_default_for_artists", sa.Boolean(), nullable=True
)
)
batch_op.add_column(
sa.Column("hd_bitrate_compression", sa.Integer(), nullable=True)
)
batch_op.add_column(
sa.Column("ld_bitrate_compression", sa.Integer(), nullable=True)
)

with op.batch_alter_table('task', schema=None) as batch_op:
batch_op.add_column(sa.Column('difficulty', sa.Integer(), nullable=True))
with op.batch_alter_table("task", schema=None) as batch_op:
batch_op.add_column(
sa.Column("difficulty", sa.Integer(), nullable=True)
)

# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('task', schema=None) as batch_op:
batch_op.drop_column('difficulty')
with op.batch_alter_table("task", schema=None) as batch_op:
batch_op.drop_column("difficulty")

with op.batch_alter_table('project', schema=None) as batch_op:
batch_op.drop_column('ld_bitrate_compression')
batch_op.drop_column('hd_bitrate_compression')
batch_op.drop_column('is_publish_default_for_artists')
with op.batch_alter_table("project", schema=None) as batch_op:
batch_op.drop_column("ld_bitrate_compression")
batch_op.drop_column("hd_bitrate_compression")
batch_op.drop_column("is_publish_default_for_artists")

with op.batch_alter_table('organisation', schema=None) as batch_op:
batch_op.drop_column('format_duration_in_hours')
batch_op.drop_column('dark_theme_by_default')
with op.batch_alter_table("organisation", schema=None) as batch_op:
batch_op.drop_column("format_duration_in_hours")
batch_op.drop_column("dark_theme_by_default")

# ### end Alembic commands ###

0 comments on commit a71be46

Please sign in to comment.