Modul Quicklinks
This commit is contained in:
parent
4355743512
commit
ee353c0675
|
|
@ -11,6 +11,9 @@ areas/migrations/*
|
|||
news/migrations/*
|
||||
!news/migrations/__init__.py
|
||||
|
||||
quicklinks/migrations/*
|
||||
!quicklinks/migrations/__init__.py
|
||||
|
||||
standards/migrations/*
|
||||
!standards/migrations/__init__.py
|
||||
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
|
|
@ -34,6 +34,7 @@ INSTALLED_APPS = [
|
|||
'areas.apps.AreasConfig',
|
||||
'orga.apps.OrgaConfig',
|
||||
'tasks.apps.TasksConfig',
|
||||
'quicklinks.apps.QuicklinksConfig',
|
||||
'standards.apps.StandardsConfig',
|
||||
'news.apps.NewsConfig',
|
||||
'crispy_forms',
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ from django.contrib.auth.decorators import login_required
|
|||
standards
|
||||
orga
|
||||
news
|
||||
quicklinkgs
|
||||
|
||||
-> Rest ist von Django
|
||||
|
||||
|
|
@ -29,6 +30,7 @@ urlpatterns = [
|
|||
path('dashboard/', include('users.urls'), name="dashboard"),
|
||||
path('areas/', include('areas.urls'), name="areas-management"),
|
||||
path('tasks/', include('tasks.urls'), name="tasks-management"),
|
||||
path('ql/', include('quicklinks.urls'), name="ql-management"),
|
||||
path('standards/', include('standards.urls'), name="standards"),
|
||||
path('news/', include('news.urls'), name="dashboard"),
|
||||
path('orga/', include('orga.urls'), name="orga"),
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,3 @@
|
|||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
class QuicklinksConfig(AppConfig):
|
||||
name = 'quicklinks'
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
from django import forms
|
||||
from django.forms import ModelForm
|
||||
from .models import QuickLinks
|
||||
|
||||
|
||||
class QlAddQlForm(forms.ModelForm):
|
||||
|
||||
class Meta:
|
||||
model =QuickLinks
|
||||
labels = {
|
||||
"name" : "Name",
|
||||
"link" : "Weblink",
|
||||
"logo" : "Logo",
|
||||
}
|
||||
fields = ['name', 'link', 'logo']
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
from django.db import models
|
||||
from users.models import Agency
|
||||
from django.urls import reverse
|
||||
from colorful.fields import RGBColorField
|
||||
from django.contrib.auth.models import User
|
||||
import datetime
|
||||
|
||||
'''
|
||||
|
||||
Model Quicklinks
|
||||
|
||||
Verwaltet alle gespeicherten Bereiche für die Agentur. Wird eine neue erstellt,
|
||||
wird dieser die Agency zugewiesen. Das Farb-Feld ist für später, damit im
|
||||
Ogranigramm eine Farbe für den jeweiligen Bereich festgelegt wird.
|
||||
|
||||
users speichert alle primary-Keys der User, welche diesem Bereich zugeordnet sind!
|
||||
|
||||
'''
|
||||
class QuickLinks(models.Model):
|
||||
|
||||
# Wenn die Area gelöscht wird, wird NICHT die Agency gelöscht
|
||||
agency = models.ForeignKey(Agency, on_delete=models.PROTECT)
|
||||
name = models.CharField(max_length=200, blank=False)
|
||||
link = models.CharField(max_length=200, blank=False)
|
||||
logo = models.ImageField(default='agencymain/default.jpg', upload_to='agencymain', blank=True)
|
||||
|
||||
def __str__(self):
|
||||
return f'{self.name}'
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse('ql-update', kwargs={'pk':self.pk})
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
{% extends "users/base.html" %}
|
||||
{% load crispy_forms_tags %}
|
||||
{% block content %}
|
||||
<div class="content-section col-6">
|
||||
<h3>Neue Quicklink anlegen</h3>
|
||||
<hr>
|
||||
<form method="POST" enctype="multipart/form-data">
|
||||
{% csrf_token %}
|
||||
{{ form|crispy }}
|
||||
<hr>
|
||||
<button type="submit" class="btn btn-success" href=" ">Aufgabe anlegen</button>
|
||||
<a class="btn" href="{% url 'ql-management' %} ">Abbrechen</a>
|
||||
</form>
|
||||
</div>
|
||||
{% endblock content %}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
{% extends "users/base.html" %}
|
||||
{% load crispy_forms_tags %}
|
||||
{% block content %}
|
||||
<div class="content-section">
|
||||
<div class="media">
|
||||
<div class="media-body">
|
||||
<h2 class="account-heading">Quicklink {{ object.name }} löschen?</h2>
|
||||
<hr>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Für das Speichern der Bilder enctype -->
|
||||
<form method="POST">
|
||||
{% csrf_token %}
|
||||
<div class="form-group">
|
||||
<button type="submit" class="btn btn-danger">Quicklink löschen</button>
|
||||
<a href="{% url 'ql-management' %}" class="btn btn-success">Abbrechen</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{% endblock content %}
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
{% extends "users/base.html" %}
|
||||
{% block content %}
|
||||
<div class="content-section col-12">
|
||||
<h3>Quicklinks</h3>
|
||||
<hr>
|
||||
<p>
|
||||
Quicklinks helfen zur schnellen Verlinkung von oft genutzten Diensten.
|
||||
</p>
|
||||
{% if perms.users.ql_management %}
|
||||
<div class="row">
|
||||
<div class="content-section col-4">
|
||||
<a class="btn btn-primary" href="{% url 'ql-addql' %}">Neuen Link anlegen</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="row mt-3">
|
||||
<div class="form-group mb-2">
|
||||
<input class="form-control" id="tableSearch" size="50" type="text" placeholder="Suche in Tabelle...">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mt-3 col-6" >
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Name</th>
|
||||
<th scope="col">Link</th>
|
||||
<th scope="col">Logo</th>
|
||||
<th scope="col"> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="tableresults">
|
||||
{% for ql in quicklinks %}
|
||||
<tr>
|
||||
<td>{{ql.name }}</td>
|
||||
<td><a href="https://{{ ql.link }}" target="_blank">{{ ql.link }}</a></td>
|
||||
<td><img src="{{ ql.logo }}"></td>
|
||||
<td>
|
||||
{% if perms.users.ql_management %}
|
||||
<div class="dropdown no-arrow">
|
||||
<a class="dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<i class="fas fa-ellipsis-v fa-sm fa-fw text-gray-400"></i>
|
||||
</a>
|
||||
<div class="dropdown-menu dropdown-menu-right shadow animated--fade-in" aria-labelledby="dropdownMenuLink">
|
||||
<a class="dropdown-item" href="{% url 'ql-update' ql.pk%}">Bearbeiten</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item text-danger" href="{% url 'ql-delete' ql.pk%}" >Löschen</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
|
||||
$(document).ready(function(){
|
||||
$("#tableSearch").on("keyup", function() {
|
||||
var value = $(this).val().toLowerCase();
|
||||
$("#tableresults tr").filter(function() {
|
||||
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock content %}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
{% extends "users/base.html" %}
|
||||
{% load crispy_forms_tags %}
|
||||
{% block content %}
|
||||
<div class="content-section col-6">
|
||||
<h3>Quicklink aktualisieren</h3>
|
||||
<hr>
|
||||
<form method="POST">
|
||||
{% csrf_token %}
|
||||
{{ form|crispy }}
|
||||
<hr>
|
||||
|
||||
<button type="submit" class="btn btn-success">Quicklink aktualisieren</button>
|
||||
<a class="btn" href="{% url 'ql-management' %} ">Abbrechen</a>
|
||||
</form>
|
||||
</div>
|
||||
{% endblock content %}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
from django.urls import path
|
||||
from django.contrib.auth import views as auth_views
|
||||
from django.contrib.auth.decorators import login_required, permission_required
|
||||
from .views import QlManagement, QlAdd, QlDeleteView, QlUpdateView
|
||||
'''
|
||||
Permissions definiert in models.py bei USERS und dann hier vor die View geschrieben!
|
||||
'''
|
||||
|
||||
urlpatterns = [
|
||||
path('', QlManagement.as_view(template_name="quicklinks/ql_management.html"), name='ql-management'),
|
||||
path('addql/', permission_required('users.ql_management')(QlAdd.as_view(template_name="quicklinks/ql_add.html")), name='ql-addql'),
|
||||
path('addql/<int:pk>/delete', permission_required('users.ql_management')(QlDeleteView.as_view()), name='ql-delete'),
|
||||
path('addql/<int:pk>/', permission_required('users.ql_management')(QlUpdateView.as_view()), name='ql-update'),
|
||||
|
||||
]
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
from django.shortcuts import render
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.views.generic import CreateView, ListView, UpdateView, DetailView, DeleteView
|
||||
from .models import QuickLinks
|
||||
from .forms import QlAddQlForm
|
||||
from django.contrib import messages
|
||||
|
||||
# Create your views here.
|
||||
class QlManagement(LoginRequiredMixin, ListView):
|
||||
model = QuickLinks
|
||||
|
||||
# Adding active_link
|
||||
# Loading only user same agency
|
||||
# Change context and return for template-data
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
quicklinks = QuickLinks.objects.filter(agency__pk=self.request.user.profile.agency.pk).order_by('name')
|
||||
context.update({'active_link' : 'quicklinks', 'quicklinks' : quicklinks})
|
||||
return context
|
||||
|
||||
class QlAdd(LoginRequiredMixin, CreateView):
|
||||
model = QuickLinks
|
||||
success_url = '/ql'
|
||||
form_class = QlAddQlForm
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context.update({'active_link' : 'quicklinks'})
|
||||
return context
|
||||
|
||||
def form_valid(self, form):
|
||||
# Send message to the site
|
||||
messages.success(self.request, f'Quicklink angelegt!')
|
||||
# SAVE OBJECTS TO SIGNALE!
|
||||
form.instance.agency = self.request.user.profile.agency
|
||||
return super().form_valid(form)
|
||||
|
||||
class QlDeleteView(LoginRequiredMixin, DeleteView):
|
||||
model = QuickLinks
|
||||
success_url = '/ql'
|
||||
template_name = 'quicklinks/ql_confirm_delete.html'
|
||||
|
||||
def delete(self, request, *args, **kwargs):
|
||||
response = super(QlDeleteView, self).delete(request, *args, **kwargs)
|
||||
messages.success(request, f'Quicklink wurde gelöscht!')
|
||||
return response
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(QlDeleteView, self).get_context_data(**kwargs)
|
||||
context['active_link'] = 'quicklinks'
|
||||
return context
|
||||
|
||||
class QlUpdateView(LoginRequiredMixin, UpdateView):
|
||||
model = QuickLinks
|
||||
template_name = 'quicklinks/ql_update.html'
|
||||
success_url = '/ql'
|
||||
form_class = QlAddQlForm
|
||||
|
||||
def form_valid(self, form):
|
||||
# Send message to the site
|
||||
messages.success(self.request, f'Quicklink aktualisiert!')
|
||||
return super().form_valid(form)
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(QlUpdateView, self).get_context_data(**kwargs)
|
||||
context['active_link'] = 'quicklinks'
|
||||
return context
|
||||
Binary file not shown.
|
|
@ -130,7 +130,8 @@ class Profile(models.Model):
|
|||
('areas_management', 'Bereiche bearbeiten'),
|
||||
('tasks_management', 'Aufgabenbereiche bearbeiten'),
|
||||
('standard_management', 'Standards bearbeiten und freischalten'),
|
||||
('news_management', 'News bearbeiten und veröffentlichen')
|
||||
('news_management', 'News bearbeiten und veröffentlichen'),
|
||||
('ql_management', 'Quicklinks bearbeiten und erstellen')
|
||||
]
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -100,6 +100,17 @@
|
|||
</a>
|
||||
</li>
|
||||
|
||||
{% if active_link == 'quicklinks' %}
|
||||
<li class="nav-item active">
|
||||
{% else%}
|
||||
<li class="nav-item">
|
||||
{%endif%}
|
||||
<a class="nav-link " href="{% url 'ql-management' %}" aria-expanded="true">
|
||||
<i class="fas fa-external-link-alt"></i>
|
||||
<span>Quicklinks</span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
{% if perms.users.users_usermanagement or perms.users.areas_management or perms.users.tasks_management or perms.user.news_management %}
|
||||
<hr class="sidebar-divider">
|
||||
<!-- Heading -->
|
||||
|
|
|
|||
Loading…
Reference in New Issue