Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
frankrousseau committed Jan 9, 2024
1 parent ac07ef5 commit a5f7ce7
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 49 deletions.
6 changes: 6 additions & 0 deletions zou/app/blueprints/crud/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,15 @@ def check_delete_permissions(self, task):

def post_update(self, instance_dict):
tasks_service.clear_task_cache(instance_dict["id"])
entity = entities_service.get_entity(instance_dict["entity_id"])
if assets_service.is_asset_dict(entity):
assets_service.clear_asset_cache(entity["id"])
elif shots_service.is_shot_dict(entity):
assets_service.clear_shot_cache(entity["id"])
return instance_dict

def pre_update(self, instance_dict, data):
print(data)
if "assignees" in data:
data["assignees"] = [
persons_service.get_person_raw(assignee)
Expand Down
103 changes: 54 additions & 49 deletions zou/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
import sys
import flask_migrate
import click
import click_extra

from sqlalchemy.exc import IntegrityError

Expand All @@ -21,10 +21,15 @@
migrations_path = os.path.join(os.path.dirname(root_path), "migrations")


@click.group()

@click_extra.extra_group(params=None)
def cli():
pass

@cli.group()
def db():
pass


@cli.command()
def version():
Expand All @@ -47,7 +52,7 @@ def init_db():


@cli.command()
@click.option("--message", default="")
@click_extra.option("--message", default="")
def migrate_db(message):
"""
Generate migration files to describe a new revision of the database schema
Expand All @@ -58,7 +63,7 @@ def migrate_db(message):


@cli.command()
@click.option("--revision", default="-1")
@click_extra.option("--revision", default="-1")
def downgrade_db(revision):
"""
Downgrade db to previous revision of the database schema
Expand Down Expand Up @@ -99,7 +104,7 @@ def upgrade_db():


@cli.command()
@click.option("--revision", default=None)
@click_extra.option("--revision", default=None)
def stamp_db(revision):
"Set the database schema revision to current one."
with app.app_context():
Expand All @@ -126,8 +131,8 @@ def reset_migrations():


@cli.command()
@click.argument("email")
@click.option("--password", required=True, default=None)
@click_extra.argument("email")
@click_extra.option("--password", required=True, default=None)
def create_admin(email, password):
"""
Create an admin user to allow usage of the API when database is empty.
Expand Down Expand Up @@ -184,7 +189,7 @@ def init_data():


@cli.command()
@click.argument("email-or-desktop-login")
@click_extra.argument("email-or-desktop-login")
def disable_two_factor_authentication(email_or_desktop_login):
"""
Disable two factor authentication for given user.
Expand All @@ -211,8 +216,8 @@ def disable_two_factor_authentication(email_or_desktop_login):


@cli.command()
@click.argument("email")
@click.option("--password", required=True, default=None)
@click_extra.argument("email")
@click_extra.option("--password", required=True, default=None)
def change_password(email, password):
"""
Change the password of given user.
Expand All @@ -229,8 +234,8 @@ def change_password(email, password):


@cli.command()
@click.argument("email")
@click.option("--unactive", is_flag=True, default=False)
@click_extra.argument("email")
@click_extra.option("--unactive", is_flag=True, default=False)
def set_person_as_active(email, unactive):
"""
Set a person as active.
Expand Down Expand Up @@ -268,11 +273,11 @@ def sync_with_ldap_server():


@cli.command()
@click.option("--source", default="http://localhost:5000")
@click.option("--project")
@click.option("--no-projects", is_flag=True)
@click.option("--with-events", is_flag=True)
@click.option("--only-projects", is_flag=True)
@click_extra.option("--source", default="http://localhost:5000")
@click_extra.option("--project")
@click_extra.option("--no-projects", is_flag=True)
@click_extra.option("--with-events", is_flag=True)
@click_extra.option("--only-projects", is_flag=True)
def sync_full(
source,
project=None,
Expand Down Expand Up @@ -301,14 +306,14 @@ def sync_full(


@cli.command()
@click.option("--source", default="http://localhost:5000", show_default=True)
@click.option("--project", default=None, show_default=True)
@click.option(
@click_extra.option("--source", default="http://localhost:5000", show_default=True)
@click_extra.option("--project", default=None, show_default=True)
@click_extra.option(
"--multithreaded", is_flag=True, show_default=True, default=False
)
@click.option("--number-workers", default=30, show_default=True, type=int)
@click.option("--number-attemps", default=3, show_default=True, type=int)
@click.option("--force-resync", is_flag=True, show_default=True, default=False)
@click_extra.option("--number-workers", default=30, show_default=True, type=int)
@click_extra.option("--number-attemps", default=3, show_default=True, type=int)
@click_extra.option("--force-resync", is_flag=True, show_default=True, default=False)
def sync_full_files(
source,
project,
Expand Down Expand Up @@ -347,9 +352,9 @@ def sync_full_files(


@cli.command()
@click.option("--event-source", default="http://localhost:8080")
@click.option("--source", default="http://localhost:8080/api")
@click.option("--logs-directory", default=None)
@click_extra.option("--event-source", default="http://localhost:8080")
@click_extra.option("--source", default="http://localhost:8080/api")
@click_extra.option("--logs-directory", default=None)
def sync_changes(event_source, source, logs_directory):
"""
Run a daemon that import data related to any change happening on source
Expand All @@ -364,9 +369,9 @@ def sync_changes(event_source, source, logs_directory):


@cli.command()
@click.option("--event-source", default="http://localhost:8080")
@click.option("--source", default="http://localhost:8080/api")
@click.option("--logs-directory", default=None)
@click_extra.option("--event-source", default="http://localhost:8080")
@click_extra.option("--source", default="http://localhost:8080/api")
@click_extra.option("--logs-directory", default=None)
def sync_file_changes(event_source, source, logs_directory):
"""
Run a daemon that download files related to any change happening on source
Expand All @@ -381,9 +386,9 @@ def sync_file_changes(event_source, source, logs_directory):


@cli.command()
@click.option("--source", default="http://localhost:8080/api")
@click.option("--minutes", default=0)
@click.option("--page-size", default=300)
@click_extra.option("--source", default="http://localhost:8080/api")
@click_extra.option("--minutes", default=0)
@click_extra.option("--page-size", default=300)
def sync_last_events(source, minutes, page_size):
"""
Retrieve last events that occured on source instance and import data related
Expand All @@ -398,9 +403,9 @@ def sync_last_events(source, minutes, page_size):


@cli.command()
@click.option("--source", default="http://localhost:8080/api")
@click.option("--minutes", default=20)
@click.option("--page-size", default=50)
@click_extra.option("--source", default="http://localhost:8080/api")
@click_extra.option("--minutes", default=20)
@click_extra.option("--page-size", default=50)
def sync_last_files(source, minutes, page_size):
"""
Retrieve last preview files and thumbnails updloaded on source instance.
Expand All @@ -424,7 +429,7 @@ def download_storage_files():


@cli.command()
@click.option("--store", is_flag=True)
@click_extra.option("--store", is_flag=True)
def dump_database(store=False):
"""
Dump database described in Zou environment variables and save it to
Expand All @@ -434,7 +439,7 @@ def dump_database(store=False):


@cli.command()
@click.option("--days", default=None)
@click_extra.option("--days", default=None)
def upload_files_to_cloud_storage(days):
"""
Upload all files related to previews to configured object storage.
Expand All @@ -443,7 +448,7 @@ def upload_files_to_cloud_storage(days):


@cli.command()
@click.option("--projectid")
@click_extra.option("--projectid")
def clean_tasks_data(projectid):
"""
Reset task models data (retake count, wip start date and end date)
Expand All @@ -453,7 +458,7 @@ def clean_tasks_data(projectid):


@cli.command()
@click.option("--days", default=90)
@click_extra.option("--days", default=90)
def remove_old_data(days):
"""
Remove old events, notifications and login logs older than 90 days
Expand All @@ -479,26 +484,26 @@ def init_search_index():


@cli.command()
@click.option("--query", default="")
@click_extra.option("--query", default="")
def search_asset(query):
""" """
commands.search_asset(query)


@cli.command()
@click.option("--project", default=None, show_default=True)
@click.option("--entity-id", default=None, show_default=True)
@click.option("--episode", default=None, show_default=True, multiple=True)
@click.option("--only-shots", is_flag=True, default=False, show_default=True)
@click.option("--only-assets", is_flag=True, default=False, show_default=True)
@click.option("--with-tiles", is_flag=True, default=False, show_default=True)
@click.option(
@click_extra.option("--project", default=None, show_default=True)
@click_extra.option("--entity-id", default=None, show_default=True)
@click_extra.option("--episode", default=None, show_default=True, multiple=True)
@click_extra.option("--only-shots", is_flag=True, default=False, show_default=True)
@click_extra.option("--only-assets", is_flag=True, default=False, show_default=True)
@click_extra.option("--with-tiles", is_flag=True, default=False, show_default=True)
@click_extra.option(
"--with-metadata", is_flag=True, default=False, show_default=True
)
@click.option(
@click_extra.option(
"--with-thumbnails", is_flag=True, default=False, show_default=True
)
@click.option(
@click_extra.option(
"--force-regenerate-tiles", is_flag=True, default=False, show_default=True
)
def generate_preview_extra(
Expand Down

0 comments on commit a5f7ce7

Please sign in to comment.