Skip to content

Commit

Permalink
Merge pull request #724 from EvanBldy/master
Browse files Browse the repository at this point in the history
various improvements
  • Loading branch information
EvanBldy authored Oct 12, 2023
2 parents 9af9713 + 8ffde87 commit e8dbb97
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 11 deletions.
7 changes: 1 addition & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
name: Build package and deploy on PyPi

on:
push:
branches:
- master
tags:
- v[0-9]+.[0-9]+.[0-9]+
on: [push, pull_request]

jobs:
build-n-publish:
Expand Down
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ install_requires =
flask_principal==0.4.0
flask_restful==0.3.10
flask_sqlalchemy==3.1.1
flask-fs2[swift, s3]==0.7.21
flask-fs2[swift, s3]==0.7.22
flask-jwt-extended==4.5.3
flask-migrate==4.0.5
flask-socketio==5.3.6
Expand All @@ -56,7 +56,7 @@ install_requires =
matterhook==0.2
meilisearch==0.28.3
OpenTimelineIO==0.15.0
orjson==3.9.7
orjson==3.9.8
pillow==10.0.1
prometheus-flask-exporter==0.22.4
psutil==5.9.5
Expand Down
25 changes: 25 additions & 0 deletions zou/app/models/entity_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from zou.app import db
from zou.app.models.serializer import SerializerMixin
from zou.app.models.base import BaseMixin
from zou.app.models.task_type import TaskType

task_type_link = db.Table(
"task_type_asset_type_link",
Expand All @@ -29,3 +30,27 @@ class EntityType(db.Model, BaseMixin, SerializerMixin):
task_types = db.relationship(
"TaskType", secondary=task_type_link, lazy="joined"
)

@classmethod
def create_from_import(cls, data):
is_update = False
task_types_ids = None
if "type" in data:
del data["type"]
if "task_types" in data:
task_types_ids = data.pop("task_types", None)
entity_type = cls.get(data["id"])
if entity_type is None:
entity_type = cls.create(**data)
is_update = False
else:
entity_type.update(data)
is_update = True
if task_types_ids is not None:
entity_type.task_types = []
for task_type_id in task_types_ids:
task_type = TaskType.get(task_type_id)
if task_type is not None:
entity_type.task_types.append(task_type)
entity_type.save()
return (entity_type, is_update)
7 changes: 4 additions & 3 deletions zou/app/services/sync_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
"shot": "shots",
"schedule-item": "schedule-items",
"search-filter": "search-filters",
"search-filter-group": "search-filter-groups",
"subscription": "subscriptions",
"task": "tasks",
"task-status": "task-status",
Expand Down Expand Up @@ -269,9 +270,9 @@ def run_other_sync(project=None, with_events=False):
"""
Retrieve and import all search filters and events from target instance.
"""
sync_entries("search-filters", SearchFilter, project=project)
sync_entries("search-filter-groups", SearchFilterGroup, project=project)
sync_entries("day-offs", SearchFilter, project=project)
sync_entries("search-filters", SearchFilter, project=project)
sync_entries("day-offs", DayOff, project=project)
if with_events:
sync_entries("events", ApiEvent, project=project)

Expand Down Expand Up @@ -363,7 +364,7 @@ def sync_entries(model_name, model, project=None):
project = gazu.project.get_project_by_name(project)
if model_name == "projects":
instances = [gazu.client.fetch_one(model_name, project.get("id"))]
elif model_name in "search-filters":
elif model_name in ["search-filters", "search-filter-groups"]:
instances = gazu.client.fetch_all(
model_name, params=dict(project_id=project.get("id"))
)
Expand Down

0 comments on commit e8dbb97

Please sign in to comment.