From 5ba82e29aa2735d175ad7566eb645de6aa804db6 Mon Sep 17 00:00:00 2001 From: Retspen Date: Mon, 16 Mar 2015 15:46:44 +0200 Subject: [PATCH] Little fix user page --- logs/views.py | 13 + templates/instance.html | 530 +++++++++--------- templates/user.html | 31 +- .../0003_remove_userinstance_is_block.py | 18 + users/models.py | 1 - users/views.py | 4 +- webvirtcloud/urls.py | 2 +- 7 files changed, 313 insertions(+), 286 deletions(-) create mode 100644 users/migrations/0003_remove_userinstance_is_block.py diff --git a/logs/views.py b/logs/views.py index 0d779d8..ff8493f 100644 --- a/logs/views.py +++ b/logs/views.py @@ -5,4 +5,17 @@ from logs.models import Logs def showlogs(request): + """ + :param request: + :return: + """ + + if not request.user.is_authenticated(): + return HttpResponseRedirect(reverse('index')) + + if not request.user.is_superuser: + return HttpResponseRedirect(reverse('index')) + + + return render(request, 'showlogs.html', locals()) \ No newline at end of file diff --git a/templates/instance.html b/templates/instance.html index 118ba79..da4e724 100644 --- a/templates/instance.html +++ b/templates/instance.html @@ -97,7 +97,7 @@ {% trans "Power Off" %} - {% if status %} + {% if request.user.is_superuser %}
  • {% trans "Suspend" %} @@ -105,13 +105,15 @@
  • {% endif %} {% endifequal %} - {% ifequal status 3 %} - - {% endifequal %} + {% if request.user.is_superuser %} + {% ifequal status 3 %} + + {% endifequal %} + {% endif %} {% ifequal status 5 %} -
  • - - {% trans "Autostart" %} - -
  • -
  • - - {% trans "VNC" %} - -
  • -
  • - - {% trans "Clone" %} - -
  • -
  • - - {% trans "Migrate" %} - -
  • -
  • - - {% trans "XML" %} - -
  • + {% if request.user.is_superuser %} +
  • + + {% trans "Autostart" %} + +
  • +
  • + + {% trans "VNC" %} + +
  • +
  • + + {% trans "Clone" %} + +
  • +
  • + + {% trans "Migrate" %} + +
  • +
  • + + {% trans "XML" %} + +
  • + {% endif %}
    @@ -441,222 +449,224 @@
    -
    -

    {% trans "Autostart your instance when host server is power on" %}

    -
    {% csrf_token %} - {% ifequal autostart 0 %} - - {% else %} - - {% endifequal %} -
    -
    -
    -
    -

    {% trans "To set console's type, shutdown the instance." %}

    -
    {% csrf_token %} -
    - -
    - -
    -
    - {% ifequal status 5 %} - - {% else %} - - {% endifequal %} -
    -
    -
    -

    {% trans "To create console password, shutdown the instance." %}

    -
    {% csrf_token %} -
    -
    -
    - -
    -
    - -
    -
    -
    -
    - -
    - -
    - {% if console_passwd %} - {% trans "Show" %} - {% endif %} -
    - {% ifequal status 5 %} - - {% else %} - - {% endifequal %} -
    -
    -
    -

    {% trans "To set console's keymap, shutdown the instance." %}

    -
    {% csrf_token %} -
    -
    -
    - -
    -
    -
    -
    - -
    - -
    -
    - {% ifequal status 5 %} - - {% else %} - - {% endifequal %} -
    -
    -
    -
    -
    -
    -

    {% trans "Create a clone" %}

    -
    {% csrf_token %} -
    - -
    - -
    -
    -

    {% trans "Network devices" %}

    - {% for network in networks %} -
    - -
    - -
    -
    - -
    -
    - {% endfor %} -

    {% trans "Storage devices" %}

    - {% for disk in clone_disks %} -
    - -
    - -
    - {% ifequal disk.format 'qcow2' %} - -
    - -
    - {% endifequal %} -
    - {% endfor %} - {% ifequal status 5 %} - - {% else %} - - {% endifequal %} -
    -
    -
    -
    -

    {% trans "For migration both host servers must have equal settings and OS type" %}

    -
    {% csrf_token %} -
    - -
    -

    {{ compute.name }}

    -
    -
    -
    - -
    - + {% else %} + + {% endifequal %} + +
    +
    +
    +

    {% trans "To set console's type, shutdown the instance." %}

    +
    {% csrf_token %} +
    + +
    + + +
    +
    + {% ifequal status 5 %} + + {% else %} + + {% endifequal %} +
    -
    -
    - -
    - + +

    {% trans "To create console password, shutdown the instance." %}

    +
    {% csrf_token %} +
    +
    +
    + +
    +
    + +
    +
    -
    -
    - -
    - +
    + +
    + +
    + {% if console_passwd %} + {% trans "Show" %} + {% endif %} +
    + {% ifequal status 5 %} + + {% else %} + + {% endifequal %} +
    -
    -
    - -
    - + +

    {% trans "To set console's keymap, shutdown the instance." %}

    +
    {% csrf_token %} +
    +
    +
    + +
    +
    -
    - {% if computes_count != 1 %} - - {% else %} - - {% endif %} - -

    -
    -
    -

    {% trans "If you need to edit xml please Power Off the instance" %}

    -
    {% csrf_token %} -
    - -
    - {% ifequal status 5 %} - - - {% else %} - - {% endifequal %} -
    -
    -
    +
    + +
    + +
    +
    + {% ifequal status 5 %} + + {% else %} + + {% endifequal %} +
    +
    + +
    +
    +
    +

    {% trans "Create a clone" %}

    +
    {% csrf_token %} +
    + +
    + +
    +
    +

    {% trans "Network devices" %}

    + {% for network in networks %} +
    + +
    + +
    +
    + +
    +
    + {% endfor %} +

    {% trans "Storage devices" %}

    + {% for disk in clone_disks %} +
    + +
    + +
    + {% ifequal disk.format 'qcow2' %} + +
    + +
    + {% endifequal %} +
    + {% endfor %} + {% ifequal status 5 %} + + {% else %} + + {% endifequal %} +
    +
    +
    +
    +

    {% trans "For migration both host servers must have equal settings and OS type" %}

    +
    {% csrf_token %} +
    + +
    +

    {{ compute.name }}

    +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    + {% if computes_count != 1 %} + + {% else %} + + {% endif %} +
    +

    +
    +
    +

    {% trans "If you need to edit xml please Power Off the instance" %}

    +
    {% csrf_token %} +
    + +
    + {% ifequal status 5 %} + + + {% else %} + + {% endifequal %} +
    +
    +
    + {% endif %}
    diff --git a/templates/user.html b/templates/user.html index 683e594..b6a8b6c 100644 --- a/templates/user.html +++ b/templates/user.html @@ -28,10 +28,9 @@ # - {% trans "Name" %} - {% trans "User blocked" %} - {% trans "Can change" %} - {% trans "Can delete" %} + {% trans "Instance" %} + {% trans "Resize" %} + {% trans "Delete" %} {% trans "Action" %} @@ -39,8 +38,7 @@ {% for inst in user_insts %} {{ forloop.counter }} - {{ inst.instance.name }} - {{ inst.is_block }} + {{ inst.instance.name }} {{ inst.is_change }} {{ inst.is_delete }} @@ -58,38 +56,29 @@ diff --git a/users/migrations/0003_remove_userinstance_is_block.py b/users/migrations/0003_remove_userinstance_is_block.py new file mode 100644 index 0000000..818c2e6 --- /dev/null +++ b/users/migrations/0003_remove_userinstance_is_block.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0002_userinstance_is_block'), + ] + + operations = [ + migrations.RemoveField( + model_name='userinstance', + name='is_block', + ), + ] diff --git a/users/models.py b/users/models.py index 850f613..2334901 100644 --- a/users/models.py +++ b/users/models.py @@ -8,7 +8,6 @@ class UserInstance(models.Model): instance = models.ForeignKey(Instance) is_change = models.BooleanField(default=False) is_delete = models.BooleanField(default=False) - is_block = models.BooleanField(default=False) def __unicode__(self): return self.instance.name \ No newline at end of file diff --git a/users/views.py b/users/views.py index 55ab801..6bc0e6d 100644 --- a/users/views.py +++ b/users/views.py @@ -90,13 +90,11 @@ def user(request, user_id): del_user_inst = UserInstance.objects.get(id=user_inst) del_user_inst.delete() return HttpResponseRedirect(request.get_full_path()) - if 'edit' in request.POST: + if 'permission' in request.POST: user_inst = request.POST.get('user_inst', '') - inst_block = request.POST.get('inst_block', '') inst_change = request.POST.get('inst_change', '') inst_delete = request.POST.get('inst_delete', '') edit_user_inst = UserInstance.objects.get(id=user_inst) - edit_user_inst.is_block = bool(inst_block) edit_user_inst.is_change = bool(inst_change) edit_user_inst.is_delete = bool(inst_delete) edit_user_inst.save() diff --git a/webvirtcloud/urls.py b/webvirtcloud/urls.py index 75a4caa..fd55e5c 100644 --- a/webvirtcloud/urls.py +++ b/webvirtcloud/urls.py @@ -22,7 +22,7 @@ urlpatterns = patterns('', url(r'^compute/net/(\d+)/([\w\-\.]+)/$', 'networks.views.network', name='network'), url(r'^compute/ifaces/(\d+)/$', 'interfaces.views.interfaces', name='interfaces'), - url(r'^compute/iface/(\d+)/([\w\.]+)$', 'interfaces.views.interface', name='interface'), + url(r'^compute/iface/(\d+)/([\w\.\:]+)$', 'interfaces.views.interface', name='interface'), url(r'^compute/secret/(\d+)/$', 'secrets.views.secrets', name='secrets'),