diff options
Diffstat (limited to 'module/web/pyload')
-rw-r--r-- | module/web/pyload/admin.py | 4 | ||||
-rw-r--r-- | module/web/pyload/models.py | 22 | ||||
-rw-r--r-- | module/web/pyload/views.py | 9 |
3 files changed, 25 insertions, 10 deletions
diff --git a/module/web/pyload/admin.py b/module/web/pyload/admin.py index 11f325200..99cb28836 100644 --- a/module/web/pyload/admin.py +++ b/module/web/pyload/admin.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- from django.contrib import admin -from models import UserProfile +from models import Prefs from django.contrib.auth.models import User from django.contrib.auth.admin import UserAdmin as RealUserAdmin class UserProfileInline(admin.StackedInline): - model = UserProfile + model = Prefs class UserAdmin(RealUserAdmin): inlines = [ UserProfileInline ] diff --git a/module/web/pyload/models.py b/module/web/pyload/models.py index d3d99febc..86962f23c 100644 --- a/module/web/pyload/models.py +++ b/module/web/pyload/models.py @@ -3,13 +3,29 @@ from django.db import models from django.contrib.auth.models import User # Create your models here. -class UserProfile(models.Model): +class Prefs(models.Model): """ Permissions setting """ user = models.ForeignKey(User, unique=True) - template = models.CharField(max_length=30, default='default', null=False, blank=False) + template = models.CharField(max_length=30, default='default', null=False, blank=False) #@TODO: currently unused + + class Meta: + permissions = ( + ('can_see_dl', 'User can see Downloads'), + ('can_change_status', 'User can change Status'), + ('can_download', 'User can download'), + ('can_add', 'User can add Links'), + ('can_delete', 'User can delete Links'), + ('can_see_logs', 'User can see Logs'), + ) + verbose_name = "Preferences" + verbose_name_plural = "Preferences" + + def __unicode__(self): + return "Preferences for %s" % self.user + def user_post_save(sender, instance, **kwargs): - profile, new = UserProfile.objects.get_or_create(user=instance) + profile, new = Prefs.objects.get_or_create(user=instance) models.signals.post_save.connect(user_post_save, User)
\ No newline at end of file diff --git a/module/web/pyload/views.py b/module/web/pyload/views.py index 6c2954555..405bd2753 100644 --- a/module/web/pyload/views.py +++ b/module/web/pyload/views.py @@ -50,29 +50,28 @@ def base(request, messages): return render_to_response(join(settings.TEMPLATE,'base.html'), {'messages': messages},RequestContext(request)) @login_required -#@permission('perm.permissions.can_see_dl') @TODO: Permissions not working :( +@permission('pyload.can_see_dl') @check_server def home(request): - print request.user.get_all_permissions() return render_to_response(join(settings.TEMPLATE,'home.html'), RequestContext(request)) @login_required -#@permission('pyload.perm.can_see_dl') +@permission('pyload.can_see_dl') @check_server def queue(request): return render_to_response(join(settings.TEMPLATE,'queue.html'), RequestContext(request)) @login_required -#@permission('pyload.user.can_download') +@permission('pyload.can_download') @check_server def downloads(request): return render_to_response(join(settings.TEMPLATE,'downloads.html'), RequestContext(request)) @login_required -#@permission('pyload.user.can_see_logs') +@permission('pyload.user.can_see_logs') @check_server def logs(request): return render_to_response(join(settings.TEMPLATE,'logs.html'), RequestContext(request)) |