Jonas Havelka
4 years ago
8 changed files with 143 additions and 64 deletions
@ -1,12 +1,10 @@ |
|||
from django.urls import path |
|||
from django.contrib.auth.decorators import user_passes_test |
|||
from seminar.utils import org_required |
|||
from . import views |
|||
|
|||
staff_member_required = user_passes_test(lambda u: u.is_staff) |
|||
|
|||
urlpatterns = [ |
|||
path('korektury/', staff_member_required(views.KorekturyAktualniListView.as_view()), name='korektury-list'), |
|||
path('korektury/zastarale/', staff_member_required(views.KorekturyZastaraleListView.as_view()), name='korektury-list'), |
|||
path('korektury/<int:pdf>/', staff_member_required(views.KorekturyView.as_view()), name='korektury'), |
|||
path('korektury/help/', staff_member_required(views.KorekturyHelpView.as_view()), name='korektury-help'), |
|||
path('korektury/', org_required(views.KorekturyAktualniListView.as_view()), name='korektury-list'), |
|||
path('korektury/zastarale/', org_required(views.KorekturyZastaraleListView.as_view()), name='korektury-list'), |
|||
path('korektury/<int:pdf>/', org_required(views.KorekturyView.as_view()), name='korektury'), |
|||
path('korektury/help/', org_required(views.KorekturyHelpView.as_view()), name='korektury-help'), |
|||
] |
|||
|
@ -1,14 +1,25 @@ |
|||
from django.urls import path |
|||
from django.contrib.auth.decorators import user_passes_test |
|||
from seminar.utils import org_required, resitel_required |
|||
from . import views |
|||
|
|||
staff_member_required = user_passes_test(lambda u: u.is_staff) |
|||
|
|||
urlpatterns = [ |
|||
path('prednasky/', views.newPrednaska), |
|||
path( |
|||
'prednasky/', |
|||
resitel_required(views.newPrednaska) |
|||
), |
|||
path('prednasky/hotovo', views.Prednaska_hotovo), |
|||
path('prednasky/metaseznam_prednasek', staff_member_required(views.MetaSeznamListView.as_view()), name='metaseznam-list'), |
|||
path('prednasky/seznam_prednasek/<int:seznam>/export', staff_member_required(views.SeznamExportView), name='seznam-export'), |
|||
path('prednasky/seznam_prednasek/<int:seznam>/', staff_member_required(views.SeznamListView.as_view()), name='seznam-list'), |
|||
# path('korektury/help/', staff_member_required(views.KorekturyHelpView.as_view()), name='korektury-help'), |
|||
path( |
|||
'prednasky/metaseznam_prednasek', |
|||
org_required(views.MetaSeznamListView.as_view()), |
|||
name='metaseznam-list'), |
|||
path( |
|||
'prednasky/seznam_prednasek/<int:seznam>/export', |
|||
org_required(views.SeznamExportView), |
|||
name='seznam-export' |
|||
), |
|||
path( |
|||
'prednasky/seznam_prednasek/<int:seznam>/', |
|||
org_required(views.SeznamListView.as_view()), |
|||
name='seznam-list' |
|||
), |
|||
] |
|||
|
@ -0,0 +1,35 @@ |
|||
# Generated by Django 2.2.15 on 2020-09-05 10:10 |
|||
from django.db import migrations |
|||
|
|||
|
|||
def add_perms(apps, schema_editor): |
|||
ContentType = apps.get_model('contenttypes', 'ContentType') |
|||
User = apps.get_model('auth', 'User') |
|||
Permission = apps.get_model('auth', 'Permission') |
|||
Resitel = apps.get_model('seminar', 'Resitel') |
|||
|
|||
c = ContentType.objects.get_for_model(User) |
|||
org_perm = Permission.objects.filter(codename__exact='org').first() |
|||
if not org_perm: |
|||
org_perm = Permission.objects.create(codename='org', name='org', content_type=c) |
|||
resitel_perm = Permission.objects.filter(codename__exact='resitel').first() |
|||
if not resitel_perm: |
|||
resitel_perm = Permission.objects.create(codename='resitel', name='resitel', content_type=c) |
|||
for r in Resitel.objects.all(): |
|||
u = r.osoba.user |
|||
if u: |
|||
u.user_permissions.add(resitel_perm) |
|||
for org in User.objects.all(): |
|||
if org and org.is_staff: |
|||
org.user_permissions.add(org_perm) |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('seminar', '0087_fix_polymorphism'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.RunPython(add_perms, migrations.RunPython.noop), |
|||
] |
Loading…
Reference in new issue