mirror of
https://github.com/retspen/webvirtcloud
synced 2025-07-31 12:41:08 +00:00
Instances overhaul
This commit is contained in:
parent
f23e6b000f
commit
47009d47ca
69 changed files with 5011 additions and 4127 deletions
|
@ -6,6 +6,9 @@ from django.utils.translation import ugettext_lazy as _
|
|||
|
||||
from instances.models import Instance
|
||||
|
||||
class UserInstanceManager(models.Manager):
|
||||
def get_queryset(self):
|
||||
return super().get_queryset().select_related('instance', 'user')
|
||||
|
||||
class UserInstance(models.Model):
|
||||
user = models.ForeignKey(User, on_delete=models.CASCADE)
|
||||
|
@ -14,6 +17,8 @@ class UserInstance(models.Model):
|
|||
is_delete = models.BooleanField(default=False)
|
||||
is_vnc = models.BooleanField(default=False)
|
||||
|
||||
objects = UserInstanceManager()
|
||||
|
||||
def __str__(self):
|
||||
return _('Instance "%(inst)s" of user %(user)s') % {'inst': self.instance, 'user': self.user}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
{% for inst in user_insts %}
|
||||
<tr>
|
||||
<td>{{ forloop.counter }}</td>
|
||||
<td><a href="{% url 'instances:instance' inst.instance.compute.id inst.instance.name %}">{{ inst.instance.name }}</a></td>
|
||||
<td><a href="{% url 'instances:instance' inst.instance.id %}">{{ inst.instance.name }}</a></td>
|
||||
<td>{{ inst.is_vnc }}</td>
|
||||
<td>{{ inst.is_change }}</td>
|
||||
<td>{{ inst.is_delete }}</td>
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
</td>
|
||||
<td>{% if user.is_staff %}<span class="fa fa-check"></span>{% endif %}</td>
|
||||
<td>{% if user.is_superuser %}<span class="fa fa-check"></span>{% endif %}</td>
|
||||
<td>{% if user.userattributes.can_clone_instances %}<span class="fa fa-check"></span>{% endif %}</td>
|
||||
<td>{% if perms.instances.clone_instances %}<span class="fa fa-check"></span>{% endif %}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
|
|
@ -126,7 +126,11 @@ def user_instance_delete(request, pk):
|
|||
if request.method == 'POST':
|
||||
user = user_instance.user
|
||||
user_instance.delete()
|
||||
return redirect(reverse('account', args=[user.id]))
|
||||
next = request.GET.get('next', None)
|
||||
if next:
|
||||
return redirect(next)
|
||||
else:
|
||||
return redirect(reverse('account', args=[user.id]))
|
||||
|
||||
return render(
|
||||
request,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue