Loading services/webapp/code/rosetta/core_app/models.py +23 −0 Original line number Diff line number Diff line Loading @@ -246,6 +246,29 @@ class Computing(models.Model): def default_container_engine(self): return self.container_engines[0] @property def container_engines_json(self): if not self.container_engines: return'' return json.dumps(self.container_engines) @property def supported_archs_json(self): if not self.supported_archs: return '' return json.dumps(self.supported_archs) @property def emulated_archs_json(self): if not self.emulated_archs: return '' return json.dumps(self.emulated_archs) @property def conf_json(self): if not self.conf: return '' return json.dumps(self.conf) #======================= # Computing manager Loading services/webapp/code/rosetta/core_app/templates/components/computing.html +11 −1 Original line number Diff line number Diff line Loading @@ -69,6 +69,16 @@ </td> </tr> {% if request.user.is_staff %} <tr> <td><b>Actions</b></td> <td> <a href="/edit_computing/?uuid={{ data.computing.uuid }}" >Edit</a> </td> </tr> {% endif %} </table> Loading @@ -80,7 +90,7 @@ {% load computing_helpers %} {% is_computing_configured computing request.user as computing_configured %} <!-- Insert an "if false" here to let the computign show up even when creating the task but to not allow to be chosen (greyed out button) --> <!-- Insert an "if false" here to let the computing show up even when creating the task but to not allow to be chosen (greyed out button) --> {% if container and not computing_configured %} {% else%} Loading services/webapp/code/rosetta/core_app/templates/edit_computing.html 0 → 100644 +79 −0 Original line number Diff line number Diff line {% load static %} {% include "header.html" %} {% include "navigation.html" %} {% include "logo.html" %} <div class="container"> <div class="dashboard"> <div class="span8 offset2"> <h1><a href="/computing">Computing resources</a> <span style="font-size:18px"> / <a href="/computing/?uuid={{ data.computing.uuid }}">{{ data.computing.name }}</a> /edit</span></h1> <hr> {% if data.error %} <div class="alert alert-danger">{{ data.error }}</div> {% endif %} {% if data.edited %} <div class="alert alert-success">Resource updated successfully.</div> {% endif %} <form action="#" method="POST"> {% csrf_token %} <table class="dashboard" style="width:500px; margin-bottom:25px"> <tr> <td><b>Name</b></td> <td><input type="text" name="name" value="{{ data.computing.name }}" size="30" required /></td> </tr> <tr> <td><b>Description</b></td> <td><textarea name="description" rows="3" cols="30">{{ data.computing.description }}</textarea></td> </tr> <tr> <td><b>Type</b></td> <td><input type="text" name="type" value="{{ data.computing.type }}" size="30" required /></td> </tr> <tr> <td><b>Arch</b></td> <td><input type="text" name="arch" value="{{ data.computing.arch }}" size="30" required /></td> </tr> <tr> <td><b>Access mode</b></td> <td><input type="text" name="access_mode" value="{{ data.computing.access_mode }}" size="30" required /></td> </tr> <tr> <td><b>Auth mode</b></td> <td><input type="text" name="auth_mode" value="{{ data.computing.auth_mode }}" size="30" required /></td> </tr> <tr> <td><b>WMS</b></td> <td><input type="text" name="wms" value="{{ data.computing.wms }}" size="30" /></td> </tr> <tr> <td><b>Container engines</b><br/><span style="font-size:0.8em">(JSON list)</span></td> <td><textarea name="container_engines" rows="2" cols="30">{{ data.computing.container_engines_json }}</textarea></td> </tr> <tr> <td><b>Supported archs</b><br/><span style="font-size:0.8em">(JSON list)</span></td> <td><textarea name="supported_archs" rows="2" cols="30">{{ data.computing.supported_archs_json }}</textarea></td> </tr> <tr> <td><b>Emulated archs</b><br/><span style="font-size:0.8em">(JSON dict)</span></td> <td><textarea name="emulated_archs" rows="2" cols="30">{{ data.computing.emulated_archs_json }}</textarea></td> </tr> <tr> <td><b>Conf</b><br/><span style="font-size:0.8em">(JSON dict)</span></td> <td><textarea name="conf" rows="2" cols="30">{{ data.computing.conf_json }}</textarea></td> </tr> </table> <table style="width:500px; border:0; background:#ffffff; margin-top:20px"> <tr><td align="center"> <a href="/computing/?uuid={{ data.computing.uuid }}" class="btn btn-primary" style="margin-left:10px">Back</a> <input type="submit" value="Save changes" class="btn btn-primary"> </td></tr> </table> </form> </div> </div> </div> {% include "footer.html" %} No newline at end of file services/webapp/code/rosetta/core_app/views.py +71 −0 Original line number Diff line number Diff line Loading @@ -1161,6 +1161,77 @@ def computing(request): return render(request, 'computing.html', {'data': data}) @private_view def edit_computing(request): data = {} data['user'] = request.user computing_uuid = request.GET.get('uuid', None) if not computing_uuid: data['error'] = 'No computing resource specified.' return render(request, 'error.html', {'data': data}) try: computing = Computing.objects.get(uuid=computing_uuid) except Computing.DoesNotExist: data['error'] = 'Computing resource does not exist.' return render(request, 'error.html', {'data': data}) # Only allow editing if user is admin (or group owner, if you want to extend) if not request.user.is_staff: data['error'] = 'You do not have permission to edit this computing resource.' return render(request, 'error.html', {'data': data}) data['computing'] = computing data['edited'] = False if request.method == 'POST': computing.name = request.POST.get('name', computing.name) computing.description = request.POST.get('description', computing.description) computing.type = request.POST.get('type', computing.type) computing.arch = request.POST.get('arch', computing.arch) computing.access_mode = request.POST.get('access_mode', computing.access_mode) computing.auth_mode = request.POST.get('auth_mode', computing.auth_mode) computing.wms = request.POST.get('wms', computing.wms) # JSON fields container_engines = request.POST.get('container_engines', None) if container_engines: try: computing.container_engines = json.loads(container_engines) except Exception: data['error'] = 'Invalid container engines format (must be JSON list).' return render(request, 'edit_computing.html', {'data': data}) supported_archs = request.POST.get('supported_archs', None) if supported_archs: try: computing.supported_archs = json.loads(supported_archs) except Exception: data['error'] = 'Invalid supported archs format (must be JSON list).' return render(request, 'edit_computing.html', {'data': data}) emulated_archs = request.POST.get('emulated_archs', None) if emulated_archs: try: computing.emulated_archs = json.loads(emulated_archs) except Exception: data['error'] = 'Invalid emulated archs format (must be JSON dict).' return render(request, 'edit_computing.html', {'data': data}) conf = request.POST.get('conf', None) if conf: try: computing.conf = json.loads(conf) except Exception: data['error'] = 'Invalid conf format (must be JSON dict).' return render(request, 'edit_computing.html', {'data': data}) try: computing.save() data['edited'] = True except Exception as e: data['error'] = f'Error saving computing resource: {e}' return render(request, 'edit_computing.html', {'data': data}) return render(request, 'edit_computing.html', {'data': data}) #========================= # Storage #========================= Loading services/webapp/code/rosetta/urls.py +1 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ urlpatterns = [ #Computing url(r'^computing/$', core_app_views.computing), url(r'^edit_computing/$', core_app_views.edit_computing), # Storage url(r'^storage/$', core_app_views.storage), Loading Loading
services/webapp/code/rosetta/core_app/models.py +23 −0 Original line number Diff line number Diff line Loading @@ -246,6 +246,29 @@ class Computing(models.Model): def default_container_engine(self): return self.container_engines[0] @property def container_engines_json(self): if not self.container_engines: return'' return json.dumps(self.container_engines) @property def supported_archs_json(self): if not self.supported_archs: return '' return json.dumps(self.supported_archs) @property def emulated_archs_json(self): if not self.emulated_archs: return '' return json.dumps(self.emulated_archs) @property def conf_json(self): if not self.conf: return '' return json.dumps(self.conf) #======================= # Computing manager Loading
services/webapp/code/rosetta/core_app/templates/components/computing.html +11 −1 Original line number Diff line number Diff line Loading @@ -69,6 +69,16 @@ </td> </tr> {% if request.user.is_staff %} <tr> <td><b>Actions</b></td> <td> <a href="/edit_computing/?uuid={{ data.computing.uuid }}" >Edit</a> </td> </tr> {% endif %} </table> Loading @@ -80,7 +90,7 @@ {% load computing_helpers %} {% is_computing_configured computing request.user as computing_configured %} <!-- Insert an "if false" here to let the computign show up even when creating the task but to not allow to be chosen (greyed out button) --> <!-- Insert an "if false" here to let the computing show up even when creating the task but to not allow to be chosen (greyed out button) --> {% if container and not computing_configured %} {% else%} Loading
services/webapp/code/rosetta/core_app/templates/edit_computing.html 0 → 100644 +79 −0 Original line number Diff line number Diff line {% load static %} {% include "header.html" %} {% include "navigation.html" %} {% include "logo.html" %} <div class="container"> <div class="dashboard"> <div class="span8 offset2"> <h1><a href="/computing">Computing resources</a> <span style="font-size:18px"> / <a href="/computing/?uuid={{ data.computing.uuid }}">{{ data.computing.name }}</a> /edit</span></h1> <hr> {% if data.error %} <div class="alert alert-danger">{{ data.error }}</div> {% endif %} {% if data.edited %} <div class="alert alert-success">Resource updated successfully.</div> {% endif %} <form action="#" method="POST"> {% csrf_token %} <table class="dashboard" style="width:500px; margin-bottom:25px"> <tr> <td><b>Name</b></td> <td><input type="text" name="name" value="{{ data.computing.name }}" size="30" required /></td> </tr> <tr> <td><b>Description</b></td> <td><textarea name="description" rows="3" cols="30">{{ data.computing.description }}</textarea></td> </tr> <tr> <td><b>Type</b></td> <td><input type="text" name="type" value="{{ data.computing.type }}" size="30" required /></td> </tr> <tr> <td><b>Arch</b></td> <td><input type="text" name="arch" value="{{ data.computing.arch }}" size="30" required /></td> </tr> <tr> <td><b>Access mode</b></td> <td><input type="text" name="access_mode" value="{{ data.computing.access_mode }}" size="30" required /></td> </tr> <tr> <td><b>Auth mode</b></td> <td><input type="text" name="auth_mode" value="{{ data.computing.auth_mode }}" size="30" required /></td> </tr> <tr> <td><b>WMS</b></td> <td><input type="text" name="wms" value="{{ data.computing.wms }}" size="30" /></td> </tr> <tr> <td><b>Container engines</b><br/><span style="font-size:0.8em">(JSON list)</span></td> <td><textarea name="container_engines" rows="2" cols="30">{{ data.computing.container_engines_json }}</textarea></td> </tr> <tr> <td><b>Supported archs</b><br/><span style="font-size:0.8em">(JSON list)</span></td> <td><textarea name="supported_archs" rows="2" cols="30">{{ data.computing.supported_archs_json }}</textarea></td> </tr> <tr> <td><b>Emulated archs</b><br/><span style="font-size:0.8em">(JSON dict)</span></td> <td><textarea name="emulated_archs" rows="2" cols="30">{{ data.computing.emulated_archs_json }}</textarea></td> </tr> <tr> <td><b>Conf</b><br/><span style="font-size:0.8em">(JSON dict)</span></td> <td><textarea name="conf" rows="2" cols="30">{{ data.computing.conf_json }}</textarea></td> </tr> </table> <table style="width:500px; border:0; background:#ffffff; margin-top:20px"> <tr><td align="center"> <a href="/computing/?uuid={{ data.computing.uuid }}" class="btn btn-primary" style="margin-left:10px">Back</a> <input type="submit" value="Save changes" class="btn btn-primary"> </td></tr> </table> </form> </div> </div> </div> {% include "footer.html" %} No newline at end of file
services/webapp/code/rosetta/core_app/views.py +71 −0 Original line number Diff line number Diff line Loading @@ -1161,6 +1161,77 @@ def computing(request): return render(request, 'computing.html', {'data': data}) @private_view def edit_computing(request): data = {} data['user'] = request.user computing_uuid = request.GET.get('uuid', None) if not computing_uuid: data['error'] = 'No computing resource specified.' return render(request, 'error.html', {'data': data}) try: computing = Computing.objects.get(uuid=computing_uuid) except Computing.DoesNotExist: data['error'] = 'Computing resource does not exist.' return render(request, 'error.html', {'data': data}) # Only allow editing if user is admin (or group owner, if you want to extend) if not request.user.is_staff: data['error'] = 'You do not have permission to edit this computing resource.' return render(request, 'error.html', {'data': data}) data['computing'] = computing data['edited'] = False if request.method == 'POST': computing.name = request.POST.get('name', computing.name) computing.description = request.POST.get('description', computing.description) computing.type = request.POST.get('type', computing.type) computing.arch = request.POST.get('arch', computing.arch) computing.access_mode = request.POST.get('access_mode', computing.access_mode) computing.auth_mode = request.POST.get('auth_mode', computing.auth_mode) computing.wms = request.POST.get('wms', computing.wms) # JSON fields container_engines = request.POST.get('container_engines', None) if container_engines: try: computing.container_engines = json.loads(container_engines) except Exception: data['error'] = 'Invalid container engines format (must be JSON list).' return render(request, 'edit_computing.html', {'data': data}) supported_archs = request.POST.get('supported_archs', None) if supported_archs: try: computing.supported_archs = json.loads(supported_archs) except Exception: data['error'] = 'Invalid supported archs format (must be JSON list).' return render(request, 'edit_computing.html', {'data': data}) emulated_archs = request.POST.get('emulated_archs', None) if emulated_archs: try: computing.emulated_archs = json.loads(emulated_archs) except Exception: data['error'] = 'Invalid emulated archs format (must be JSON dict).' return render(request, 'edit_computing.html', {'data': data}) conf = request.POST.get('conf', None) if conf: try: computing.conf = json.loads(conf) except Exception: data['error'] = 'Invalid conf format (must be JSON dict).' return render(request, 'edit_computing.html', {'data': data}) try: computing.save() data['edited'] = True except Exception as e: data['error'] = f'Error saving computing resource: {e}' return render(request, 'edit_computing.html', {'data': data}) return render(request, 'edit_computing.html', {'data': data}) #========================= # Storage #========================= Loading
services/webapp/code/rosetta/urls.py +1 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ urlpatterns = [ #Computing url(r'^computing/$', core_app_views.computing), url(r'^edit_computing/$', core_app_views.edit_computing), # Storage url(r'^storage/$', core_app_views.storage), Loading