diff --git a/spkrepo/app.py b/spkrepo/app.py index ee63518..55083ea 100644 --- a/spkrepo/app.py +++ b/spkrepo/app.py @@ -15,6 +15,7 @@ IndexView, PackageView, ScreenshotView, + ServiceView, SpkrepoConfirmRegisterForm, UserView, VersionView, @@ -52,6 +53,7 @@ def create_app(config=None, register_blueprints=True, init_admin=True): admin.add_view(UserView()) admin.add_view(ArchitectureView()) admin.add_view(FirmwareView()) + admin.add_view(ServiceView()) admin.add_view(ScreenshotView()) admin.add_view(PackageView()) admin.add_view(VersionView()) diff --git a/spkrepo/views/__init__.py b/spkrepo/views/__init__.py index 2312443..8425c5b 100644 --- a/spkrepo/views/__init__.py +++ b/spkrepo/views/__init__.py @@ -6,6 +6,7 @@ IndexView, PackageView, ScreenshotView, + ServiceView, UserView, VersionView, ) diff --git a/spkrepo/views/admin.py b/spkrepo/views/admin.py index 955861d..943ecff 100644 --- a/spkrepo/views/admin.py +++ b/spkrepo/views/admin.py @@ -16,7 +16,16 @@ from wtforms.validators import Regexp from ..ext import db -from ..models import Architecture, Build, Firmware, Package, Screenshot, User, Version +from ..models import ( + Architecture, + Build, + Firmware, + Package, + Screenshot, + Service, + User, + Version, +) from ..utils import SPK @@ -111,6 +120,21 @@ def is_accessible(self): can_delete = False +class ServiceView(ModelView): + """View for :class:`~spkrepo.models.Service`""" + + def __init__(self, **kwargs): + super(ServiceView, self).__init__(Service, db.session, **kwargs) + + # Permissions + def is_accessible(self): + return current_user.is_authenticated and current_user.has_role("package_admin") + + can_edit = False + + can_delete = False + + def screenshot_namegen(obj, file_data): pattern = "screenshot_%0d%s" ext = os.path.splitext(file_data.filename)[1] diff --git a/spkrepo/views/api.py b/spkrepo/views/api.py index 5d4565d..9580bfd 100644 --- a/spkrepo/views/api.py +++ b/spkrepo/views/api.py @@ -130,6 +130,16 @@ def post(self): if firmware is None: abort(422, message="Unknown firmware") + # Services + input_install_dep_services = spk.info.get("install_dep_services", None) + if input_install_dep_services: + for info_dep_service in input_install_dep_services.split(): + service_name = Service.find(info_dep_service) + if service_name is None: + abort( + 422, message="Unknown dependent service: %s" % info_dep_service + ) + # Package create_package = False package = Package.find(spk.info["package"])