Skip to content
This repository has been archived by the owner on Mar 17, 2024. It is now read-only.

Commit

Permalink
Feature/SK-342 | Remove access to URL for rule "user can create" (#80)
Browse files Browse the repository at this point in the history
Co-authored-by: Fredrik Wrede <fredrik@scaleoutsystems.com>
  • Loading branch information
niklastheman and Wrede authored Feb 28, 2023
1 parent 438d8f3 commit f625f0d
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
from django.apps import apps
from django.conf import settings
from django.contrib.auth import get_user_model
from django.http import HttpRequest

import apps.tasks as apptasks
import apps.views as appviews
from apps.controller import delete
from apps.helpers import create_app_instance

from .exceptions import ProjectCreationException
from .models import S3, Environment, Flavor, MLFlow, Project
Expand Down Expand Up @@ -106,20 +105,26 @@ def create_resources_from_template(user, project_slug, template):
data = {**data, **item}
print("DATA TEMPLATE")
print(data)
request = HttpRequest()
request.user = User.objects.get(username=user)

create_view = appviews.CreateView()
_ = create_view.post(
request=request,
user=user,
project=project.slug,
app_slug=item["slug"],

user_obj = User.objects.get(username=user)

app = Apps.objects.filter(slug=item["slug"]).order_by(
"-revision"
)[0]

(successful, _, _,) = create_app_instance(
user=user_obj,
project=project,
app=app,
app_settings=app.settings,
data=data,
wait=True,
call=True,
)

if not successful:
print("create_app_instance failed")
raise (ProjectCreationException)

elif "settings" == key:
print("PARSING SETTINGS")
print("Settings: {}".format(settings))
Expand Down

0 comments on commit f625f0d

Please sign in to comment.