Skip to content

Commit

Permalink
fix sharing of images in frontend, fix api query for images
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Glatthard committed Aug 30, 2015
1 parent 9c53c6e commit b0eb0f7
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 19 deletions.
2 changes: 1 addition & 1 deletion ipynbsrv/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ def get_queryset(self):
collab_group = self.request.user.backend_user.get_collaboration_group()
if collab_group:
queryset = ContainerImage.objects.filter(
Q(is_internal=False) & (Q(owner=self.request.user) | Q(is_public=True) | Q(access_groups=collab_group))
Q(is_internal=False) & (Q(owner=self.request.user) | Q(is_public=True) | Q(access_groups__user=self.request.user))
).distinct()
else:
queryset = ContainerImage.objects.filter(
Expand Down
6 changes: 6 additions & 0 deletions ipynbsrv/web/templates/web/containers/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ <h1>Containers</h1>
<script src="{% static 'bower_components/bootstrap-confirmation2/bootstrap-confirmation.min.js' %}"></script>
<script>
$(function () {

{% if request.create %}
$('#modal-create-container').modal('show');
$('#modal-create-container #img_select').multiselect('select', img);
{% endif %}

$('[data-toggle="confirmation"]').confirmation({
popout: true
});
Expand Down
2 changes: 1 addition & 1 deletion ipynbsrv/web/templates/web/containers/modal_create.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h4 class="modal-title">New container</h4>
<div class="form-group">
<label for="image">Image</label>
<div class="select">
<select name="image_id" class="form-control enableCaseInsensitiveFiltering" required>
<select id="img_select" name="image_id" class="form-control enableCaseInsensitiveFiltering" required>
<option value="" selected>None</option>
{% for img in images %}
<option value="{{ img.id }}">{{ img.friendly_name }}</option>
Expand Down
11 changes: 7 additions & 4 deletions ipynbsrv/web/templates/web/images/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<div class="col-xs-12">
{% include 'web/snippets/messages.html' with messages=messages only %}

<h1>Images</h1>
<h1>Images {{ request.share }}</h1>
<form role="form">
<button id="modal-create-image_button" type="button" class="btn btn-primary btn-create pull-right" data-toggle="modal" data-target="#modal-create-image" {% if not containers %}disabled{% endif %}>Create new</button>
</form>
Expand Down Expand Up @@ -60,7 +60,7 @@ <h1>Images</h1>
<div class="alert alert-info">No images you can access available.</div>
{% endif %}

{% include 'web/images/modal_create.html' with containers=containers selected=selected share=share csrf_token=csrf_token only %}
{% include 'web/images/modal_create.html' with containers=containers selected=selected share=request.share ct=request.ct csrf_token=csrf_token only %}
</div>
</div>
{% endblock %}
Expand All @@ -70,9 +70,12 @@ <h1>Images</h1>
<script src="{% static 'bower_components/datatables-plugins-bootstrap3/dist/js/datatables-plugins-bootstrap3.min.js' %}"></script>
<script src="{% static 'bower_components/bootstrap-confirmation2/bootstrap-confirmation.min.js' %}"></script>
<script>

$(function () {
{% if selected %}
$('#modal-create-image_button').click();

{% if request.share %}
$('#modal-create-image').modal('show');
$('#modal-create-image #ct_select').multiselect('select', {{ request.ct }} );
{% endif %}

$('[data-toggle="confirmation"]').confirmation({
Expand Down
23 changes: 15 additions & 8 deletions ipynbsrv/web/templates/web/images/manage.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,21 @@
{% include 'web/snippets/messages.html' with messages=messages only %}

<h1>Image</h1>
{% if request.user.id == image.owner.id %}
<form action="{% url 'image_delete' %}" method="POST" role="form">
{% csrf_token %}
<input type="hidden" name="id" value="{{ image.id }}">
<button class="btn btn-danger btn-create pull-right" title="Delete this image?" data-toggle="confirmation" data-placement="bottom">Delete Image
</button>
</form>
{% endif %}
<fieldset class="btn-create pull-right">
<!--<form action="{% url 'containers' %}" method="GET" role="form">
{% csrf_token %}
<input type="hidden" name="img" value="{{ image.id }}">
<input type="hidden" name="share" value="1">
<button class="btn btn-primary" title="Create container">Create Container</button>
</form>-->
{% if request.user.id == image.owner.id %}
<form action="{% url 'image_delete' %}" method="POST" role="form">
{% csrf_token %}
<input type="hidden" name="id" value="{{ image.id }}">
<button class="btn btn-danger" title="Delete this image?" data-toggle="confirmation" data-placement="bottom">Delete Image</button>
</form>
{% endif %}
</fieldset>
<table class="table table-hover table-striped" cellspacing="0" width="100%">
<thead>
<tr>
Expand Down
6 changes: 3 additions & 3 deletions ipynbsrv/web/templates/web/images/modal_create.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ <h4 class="modal-title">New image</h4>
<div class="form-group">
<label for="ct_id">Base container</label>
<div class="select">
<select name="ct_id" class="form-control enableCaseInsensitiveFiltering" required>
<select id="ct_select" name="ct_id" class="form-control enableCaseInsensitiveFiltering" required>
<option value="" selected>None</option>
{% for ct in containers %}
<option value="{{ ct.id }}"{% if ct == selected %} selected{% endif %}>{{ ct.name }}</option>
{% for c in containers %}
<option value="{{ c.id }}"{% if c == selected %} selected {% endif %}>{{ c.name }}</option>
{% endfor %}
</select>
</div>
Expand Down
3 changes: 2 additions & 1 deletion ipynbsrv/web/views/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ def index(request):
'title': "Containers",
'containers': containers,
'images': images,
'new_notifications_count': new_notifications_count
'new_notifications_count': new_notifications_count,
'request': request.GET
})


Expand Down
3 changes: 2 additions & 1 deletion ipynbsrv/web/views/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ def index(request):
'title': "Images",
'containers': containers,
'images': images,
'new_notifications_count': new_notifications_count
'new_notifications_count': new_notifications_count,
'request': request.GET
})


Expand Down

0 comments on commit b0eb0f7

Please sign in to comment.