Skip to content

Commit

Permalink
add short description and access_groups to image
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Glatthard committed Aug 12, 2015
1 parent 1465d1a commit 969d1ea
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 7 deletions.
23 changes: 20 additions & 3 deletions ipynbsrv/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ def clone(self, name, description=None):

return clone

def commit(self, name, description=None, public=False):
def commit(self, name, description=None, short_description=None, public=False):
"""
Create a new container image based on the container.
Expand All @@ -581,6 +581,7 @@ def commit(self, name, description=None, public=False):
"""
image = ContainerImage(
name=name,
short_description=short_description,
description=description,
command=self.image.command,
protected_port=self.image.protected_port,
Expand Down Expand Up @@ -781,8 +782,24 @@ class ContainerImage(models.Model):
)
]
)
description = models.TextField(blank=True, null=True)
# TODO: document placeholders
short_description = models.CharField(
blank=True,
null=True,
max_length=255,
help_text='A short description of the container image.'
)
description = models.TextField(
blank=True,
null=True,
help_text='Detailed information on how to use this image.'
)
access_groups = models.ManyToManyField(
'CollaborationGroup',
blank=True,
related_name='images',
help_text='The groups having access to that image.'
)

command = models.CharField(
blank=True,
null=True,
Expand Down
4 changes: 2 additions & 2 deletions ipynbsrv/web/templates/web/images/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ <h1>Images</h1>
<thead>
<tr>
<th width="25%">Name</th>
<th width="55%">Description</th>
<th width="55%">Short Description</th>
<th width="10%" style="text-align: center">Public</th>
<th width="10%" style="text-align: right">Actions</th>
</tr>
Expand All @@ -33,7 +33,7 @@ <h1>Images</h1>
{% for img in images %}
<tr>
<td>{{ img.friendly_name }}</td>
<td>{{ img.description }}</td>
<td>{{ img.short_description }}</td>
<td style="text-align: center">
<input type="checkbox" data-sort="1"{% if img.is_public %} checked{% endif %}{% if img.owner != request.user.id %} disabled{% endif %}>
</td>
Expand Down
4 changes: 4 additions & 0 deletions ipynbsrv/web/templates/web/images/modal_create.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ <h4 class="modal-title">New image</h4>
<input name="img_name" type="text" pattern="^[A-z][\w\/]*$" class="form-control" placeholder="e.g fhnw-maths " required>
<p class="help-block">Allowed pattern: ^[A-z][\w\/]*$</p>
</div>
<div class="form-group">
<label for="short_description">Short description</label>
<input name="short_description" type="text" class="form-control">
</div>
<div class="form-group">
<label for="description">Description</label>
<textarea name="description" class="form-control" rows="3" placeholder="..."></textarea>
Expand Down
9 changes: 7 additions & 2 deletions ipynbsrv/web/views/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,19 @@ def commit(request):
messages.error(request, "Invalid request method.")
return redirect('images')
if 'ct_id' not in request.POST or not request.POST.get('ct_id').isdigit() \
or 'img_name' not in request.POST or 'description' not in request.POST:
or 'img_name' not in request.POST:
messages.error(request, "Invalid POST request.")
return redirect('images')

params = {}
ct_id = int(request.POST.get('ct_id'))
params["name"] = request.POST.get('img_name')
params["description"] = request.POST.get('description')
description = request.POST.get('description', None)
if description:
params["description"] = description
short_description = request.POST.get('short_description', None)
if short_description:
params["short_description"] = short_description
params["public"] = request.POST.get('public', "") == "on"

client = get_httpclient_instance(request)
Expand Down

0 comments on commit 969d1ea

Please sign in to comment.