Commit cc40257a by Kálmán Viktor

dashboard: store remove

parent 7162b53d
...@@ -749,7 +749,7 @@ textarea[name="list-new-namelist"] { ...@@ -749,7 +749,7 @@ textarea[name="list-new-namelist"] {
} }
.store-list-file-infos { .store-list-file-infos {
padding: 20px; padding: 15px;
display: none; display: none;
border-left: 1px solid #ddd; border-left: 1px solid #ddd;
border-right: 1px solid #ddd; border-right: 1px solid #ddd;
...@@ -768,8 +768,15 @@ textarea[name="list-new-namelist"] { ...@@ -768,8 +768,15 @@ textarea[name="list-new-namelist"] {
.store-download-button { .store-download-button {
position: absolute; position: absolute;
right: 15px; right: 15px;
top: 32px; top: 18px;
} }
.store-remove-button {
position: absolute;
right: 15px;
top: 55px;
}
.store-list-item-icon-directory { .store-list-item-icon-directory {
color: #ff8c00; color: #ff8c00;
} }
...@@ -41,16 +41,21 @@ ...@@ -41,16 +41,21 @@
<a href="{% url "dashboard.views.store-download" %}?path={{ f.path }}" <a href="{% url "dashboard.views.store-download" %}?path={{ f.path }}"
class="btn btn-primary btn-sm store-download-button"> class="btn btn-primary btn-sm store-download-button">
<i class="icon-download"></i> <i class="icon-download"></i>
Download {% trans "Download" %}
</a>
<a href="{% url "dashboard.views.store-remove" %}?path={{ f.path }}"
class="btn btn-danger btn-xs store-remove-button">
<i class="icon-remove"></i>
{% trans "Remove" %}
</a> </a>
<dl class="dl-horizontal" style="margin: 0; padding: 0;"> <dl class="dl-horizontal" style="margin: 0; padding: 0;">
<dt>Filename</dt> <dt>{% trans "Filename" %}</dt>
<dd>{{ f.NAME }}</dd> <dd>{{ f.NAME }}</dd>
<dt>Size</dt> <dt>{% trans "Size" %}</dt>
<dd>{{ f.human_readable_size }}</dd> <dd>{{ f.human_readable_size }}</dd>
<dt>Latest modification</dt> <dt>{% trans "Latest modification" %}</dt>
<dd>{{ f.human_readable_date }}</dd> <dd>{{ f.human_readable_date }}</dd>
</dl> </dl>
</div> </div>
......
{% extends "dashboard/base.html" %}
{% load i18n %}
{% block content %}
<div class="body-content">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="no-margin">
<i class="icon-remove"></i>
{% if is_dir %}
{% trans "Directory removal confirmation" %}
{% else %}
{% trans "File removal confirmation" %}
{% endif %}
</h3>
</div>
<div class="panel-body">
{% if not is_dir %}
<h4>{% trans "File directory" %}: {{ directory }}</h4>
<h4>{% trans "File name" %}: {{ name }}</h4>
{% blocktrans with path=path %}
Are you sure you want to remove the file at <strong>{{ path }}</strong>?
{% endblocktrans %}
{% else %}
{% blocktrans with directory=directory name=name %}
Are you sure you want to remove the directory <strong>{{ directory }}</strong>?
{% endblocktrans %}
{% endif %}
<div class="pull-right">
<form action="" method="POST">
{% csrf_token %}
<a href="{% url "dashboard.views.store-list" %}?directory={{ directory }}"
class="btn btn-default">{% trans "Cancel" %}</a>
<input type="hidden" name="path" value="{{ path }}"/>
<button class="btn btn-danger">{% trans "Remove" %}</button>
</form>
</div>
</div>
</div>
</div>
{% endblock %}
...@@ -37,7 +37,7 @@ from .views import ( ...@@ -37,7 +37,7 @@ from .views import (
get_vm_screenshot, get_vm_screenshot,
ProfileView, toggle_use_gravatar, UnsubscribeFormView, ProfileView, toggle_use_gravatar, UnsubscribeFormView,
UserKeyDelete, UserKeyDetail, UserKeyCreate, UserKeyDelete, UserKeyDetail, UserKeyCreate,
StoreList, store_download, store_upload, store_get_upload_url, StoreList, store_download, store_upload, store_get_upload_url, StoreRemove,
) )
urlpatterns = patterns( urlpatterns = patterns(
...@@ -179,4 +179,6 @@ urlpatterns = patterns( ...@@ -179,4 +179,6 @@ urlpatterns = patterns(
name="dashboard.views.store-upload-url"), name="dashboard.views.store-upload-url"),
url(r"^store/upload/$", store_upload, url(r"^store/upload/$", store_upload,
name="dashboard.views.store-upload"), name="dashboard.views.store-upload"),
url(r"^store/remove/$", StoreRemove.as_view(),
name="dashboard.views.store-remove"),
) )
# Copyright 2014 Budapest University of Technology and Economics (BME IK) # Copyright 2014 Budapest University of Technology and Economics (BME IK)
# #
# This file is part of CIRCLE Cloud. # This file is part of CIRCLE Cloud.
# #
...@@ -19,6 +20,7 @@ from __future__ import unicode_literals, absolute_import ...@@ -19,6 +20,7 @@ from __future__ import unicode_literals, absolute_import
from itertools import chain from itertools import chain
from os import getenv from os import getenv
import os
import json import json
import logging import logging
import re import re
...@@ -27,6 +29,7 @@ import requests ...@@ -27,6 +29,7 @@ import requests
from django.conf import settings from django.conf import settings
from django.contrib.auth.models import User, Group from django.contrib.auth.models import User, Group
from django.contrib.auth.views import login, redirect_to_login from django.contrib.auth.views import login, redirect_to_login
from django.contrib.auth.decorators import login_required
from django.contrib.messages import warning from django.contrib.messages import warning
from django.contrib.messages.views import SuccessMessageMixin from django.contrib.messages.views import SuccessMessageMixin
from django.core.exceptions import ( from django.core.exceptions import (
...@@ -2985,6 +2988,7 @@ class StoreList(LoginRequiredMixin, TemplateView): ...@@ -2985,6 +2988,7 @@ class StoreList(LoginRequiredMixin, TemplateView):
@require_GET @require_GET
@login_required
def store_download(request): def store_download(request):
path = request.GET.get("path") path = request.GET.get("path")
url = store_api.requestdownload("test", path) url = store_api.requestdownload("test", path)
...@@ -2992,6 +2996,7 @@ def store_download(request): ...@@ -2992,6 +2996,7 @@ def store_download(request):
@require_GET @require_GET
@login_required
def store_upload(request): def store_upload(request):
directory = request.GET.get("directory") directory = request.GET.get("directory")
action = store_api.requestupload("test", directory) action = store_api.requestupload("test", directory)
...@@ -3005,8 +3010,44 @@ def store_upload(request): ...@@ -3005,8 +3010,44 @@ def store_upload(request):
@require_GET @require_GET
@login_required
def store_get_upload_url(request): def store_get_upload_url(request):
current_dir = request.GET.get("current_dir") current_dir = request.GET.get("current_dir")
url = store_api.requestupload("test", current_dir) url = store_api.requestupload("test", current_dir)
return HttpResponse( return HttpResponse(
json.dumps({'url': url}), content_type="application/json") json.dumps({'url': url}), content_type="application/json")
class StoreRemove(LoginRequiredMixin, TemplateView):
template_name = "dashboard/store/remove.html"
def get_context_data(self, *args, **kwargs):
context = super(StoreRemove, self).get_context_data(*args, **kwargs)
path = self.request.GET.get("path", "/")
if path == "/":
SuspiciousOperation()
context['path'] = path
context['is_dir'] = path.endswith("/")
if context['is_dir']:
context['directory'] = path
else:
context['directory'] = os.path.dirname(path)
context['name'] = os.path.basename(path)
return context
def post(self, *args, **kwargs):
path = self.request.POST.get("path")
store_api.requestremove("test", path)
if path.endswith("/"):
return redirect("%s?directory=%s" % (
reverse("dashboard.views.store-list"),
os.path.dirname(os.path.dirname(path)),
))
else:
return redirect("%s?directory=%s" % (
reverse("dashboard.views.store-list"),
os.path.dirname(path),
))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment