Skip to content

Commit

Permalink
Merge pull request #328 from MerginMaps/revert-320-create_project_signal
Browse files Browse the repository at this point in the history
Revert "Create project in tests"
  • Loading branch information
MarcelGeo authored Nov 12, 2024
2 parents ee90a3e + d2fdada commit 31ff49d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
3 changes: 0 additions & 3 deletions server/mergin/sync/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@

Storages = {"local": DiskStorage}
project_deleted = signal("project_deleted")
project_version_created = signal("project_version_created")


class PushChangeType(Enum):
Expand Down Expand Up @@ -809,8 +808,6 @@ def __init__(
self.project_size = self.project.disk_usage
db.session.flush()

project_version_created.send(self)

@staticmethod
def from_v_name(name: str) -> int:
"""Parsed version name as integer (v5 -> 5)"""
Expand Down
5 changes: 3 additions & 2 deletions server/mergin/sync/private_api_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,20 @@
from flask import render_template, request, current_app, jsonify, abort
from flask_login import current_user
from sqlalchemy.orm import defer
from sqlalchemy import text
from sqlalchemy import text, and_, desc, asc

from .. import db
from ..auth import auth_required
from ..auth.models import User, UserProfile
from .forms import AccessPermissionForm
from .models import Project, AccessRequest, ProjectRole, RequestStatus
from .models import Project, AccessRequest, ProjectRole, RequestStatus, ProjectVersion
from .schemas import (
ProjectListSchema,
ProjectAccessRequestSchema,
AdminProjectSchema,
ProjectAccessSchema,
ProjectAccessDetailSchema,
ProjectVersionListSchema,
)
from .permissions import (
require_project_by_uuid,
Expand Down
6 changes: 6 additions & 0 deletions server/mergin/sync/public_api_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from typing import Dict
from urllib.parse import quote
import uuid
from time import time
from datetime import datetime
import psycopg2
from blinker import signal
Expand Down Expand Up @@ -86,6 +87,7 @@
from ..utils import format_time_delta

push_triggered = signal("push_triggered")
project_version_created = signal("project_version_created")


def parse_project_access_update_request(access: Dict) -> Dict:
Expand Down Expand Up @@ -232,6 +234,7 @@ def add_project(namespace): # noqa: E501
db.session.add(pa)
db.session.add(version)
db.session.commit()
project_version_created.send(version)
return NoContent, 200


Expand Down Expand Up @@ -870,6 +873,7 @@ def project_push(namespace, project_name):
f"A project version {ProjectVersion.to_v_name(next_version)} for project: {project.id} created. "
f"Transaction id: {upload.id}. No upload."
)
project_version_created.send(pv)
return jsonify(ProjectSchema().dump(project)), 200
except IntegrityError as err:
db.session.rollback()
Expand Down Expand Up @@ -1079,6 +1083,7 @@ def push_finish(transaction_id):
logging.info(
f"Push finished for project: {project.id}, project version: {v_next_version}, transaction id: {transaction_id}."
)
project_version_created.send(pv)
except (psycopg2.Error, FileNotFoundError, DataSyncError, IntegrityError) as err:
db.session.rollback()
logging.exception(
Expand Down Expand Up @@ -1210,6 +1215,7 @@ def clone_project(namespace, project_name): # noqa: E501
db.session.add(pa)
db.session.add(project_version)
db.session.commit()
project_version_created.send(project_version)
return NoContent, 200


Expand Down
1 change: 1 addition & 0 deletions server/mergin/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from dataclasses import asdict
from datetime import datetime

import pysqlite3
from flask import url_for, current_app
import os
from dateutil.tz import tzlocal
Expand Down

0 comments on commit 31ff49d

Please sign in to comment.