Skip to content

Commit

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

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


class PushChangeType(Enum):
Expand Down Expand Up @@ -809,6 +810,8 @@ 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: 2 additions & 3 deletions server/mergin/sync/private_api_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,19 @@
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, and_, desc, asc
from sqlalchemy import text

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, ProjectVersion
from .models import Project, AccessRequest, ProjectRole, RequestStatus
from .schemas import (
ProjectListSchema,
ProjectAccessRequestSchema,
AdminProjectSchema,
ProjectAccessSchema,
ProjectAccessDetailSchema,
ProjectVersionListSchema,
)
from .permissions import (
require_project_by_uuid,
Expand Down
6 changes: 0 additions & 6 deletions server/mergin/sync/public_api_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
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 @@ -87,7 +86,6 @@
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 @@ -234,7 +232,6 @@ 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 @@ -873,7 +870,6 @@ 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 @@ -1083,7 +1079,6 @@ 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 @@ -1215,7 +1210,6 @@ 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: 0 additions & 1 deletion server/mergin/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
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 1eb1070

Please sign in to comment.