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

Commit 2f8b60e

Browse files
Merge branch 'feature/STACKN-51' into serve-path-based
2 parents 697ae0d + 13527e8 commit 2f8b60e

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

components/studio/models/templates/models_details.html

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,40 @@ <h2>{{ model.name }}</h2>
7272
{% endif %}
7373
</div>
7474
</div>
75+
<form method="POST" action="{% url 'models:change_access' request.user model.project.slug model.id %}">
76+
{% csrf_token %}
77+
78+
<div class="d-flex bd-highlight mb-3 col-md-6">
79+
<label for="id_access" class="p-2 bd-highlight" style="font-weight: bold;">
80+
Visibility
81+
</label>
82+
<select id="id_access" type="text" name="access" maxlength="2" required
83+
class="ml-auto form-control form-control-sm" style="width: 20%;">
84+
<option selected>
85+
{% if model.access == 'PR' %}
86+
Private
87+
{% elif model.access == 'PU' %}
88+
Public
89+
{% else %}
90+
Limited
91+
{% endif %}
92+
</option>
93+
{% for choice in model_access_choices %}
94+
{% if choice == 'PR' %}
95+
<option value="PR">Private</option>
96+
{% elif choice == 'PU' %}
97+
<option value="PU">Public</option>
98+
{% else %}
99+
<option value="LI">Limited</option>
100+
{% endif %}
101+
{% endfor%}
102+
</select>
103+
</div>
104+
<div class="d-flex bd-highlight mb-3 col-md-6"
105+
style="border-top: 1px solid #dee2e6; padding-top: 20px;">
106+
<button type="submit" class="ml-auto btn btn-primary">Save</button>
107+
</div>
108+
</form>
75109
</div>
76110
<div class="tab-pane fade" id="deployments" role="tabpanel" aria-labelledby="profile-tab">
77111
{% if deployments %}

components/studio/models/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@
1111
path('<user>/<project>/models/<int:id>', views.details, name='details'),
1212
path('models/<int:id>', views.details_public, name='details_public'),
1313
path('<user>/<project>/models/<int:id>/delete', views.delete, name='delete'),
14+
path('<user>/<project>/models/<int:id>/access', views.change_access, name='change_access'),
1415
]

components/studio/models/views.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,26 @@ def create(request, user, project):
6060
return render(request, template, locals())
6161

6262

63+
@login_required(login_url='/accounts/login')
64+
def change_access(request, user, project, id):
65+
model = Model.objects.filter(pk=id).first()
66+
67+
if request.method == 'POST':
68+
visibility = request.POST.get('access', '')
69+
if visibility != model.access:
70+
model.access = visibility
71+
model.save()
72+
73+
return HttpResponseRedirect(
74+
reverse('models:details', kwargs={'user': user, 'project': project, 'id': id}))
75+
76+
6377
@login_required(login_url='/accounts/login')
6478
def details(request, user, project, id):
6579
project = Project.objects.filter(slug=project).first()
6680
model = Model.objects.filter(id=id).first()
81+
model_access_choices = ['PU', 'PR', 'LI']
82+
model_access_choices.remove(model.access)
6783
deployments = DeploymentInstance.objects.filter(model=model)
6884

6985
report_generators = ReportGenerator.objects.filter(project=project)

0 commit comments

Comments
 (0)