diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2009-12-16 17:09:14 +0100 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2009-12-16 17:09:14 +0100 |
commit | fe85f003f3adfb568c8b1a650035128c183a739d (patch) | |
tree | 3abde88d3554831e0a41e3fd2d5d4092fd677a1f /module/web/pyload | |
parent | re-added progressbar (diff) | |
download | pyload-fe85f003f3adfb568c8b1a650035128c183a739d.tar.xz |
some Webinterface Json Code
Diffstat (limited to 'module/web/pyload')
-rw-r--r-- | module/web/pyload/admin.py | 14 | ||||
-rw-r--r-- | module/web/pyload/models.py | 26 | ||||
-rw-r--r-- | module/web/pyload/urls.py | 22 | ||||
-rw-r--r-- | module/web/pyload/views.py | 4 |
4 files changed, 43 insertions, 23 deletions
diff --git a/module/web/pyload/admin.py b/module/web/pyload/admin.py index 40a96afc6..11f325200 100644 --- a/module/web/pyload/admin.py +++ b/module/web/pyload/admin.py @@ -1 +1,15 @@ # -*- coding: utf-8 -*- +from django.contrib import admin +from models import UserProfile +from django.contrib.auth.models import User +from django.contrib.auth.admin import UserAdmin as RealUserAdmin + + +class UserProfileInline(admin.StackedInline): + model = UserProfile + +class UserAdmin(RealUserAdmin): + inlines = [ UserProfileInline ] + +admin.site.unregister(User) +admin.site.register(User, UserAdmin)
\ No newline at end of file diff --git a/module/web/pyload/models.py b/module/web/pyload/models.py index 293c01109..d3d99febc 100644 --- a/module/web/pyload/models.py +++ b/module/web/pyload/models.py @@ -1,21 +1,15 @@ # -*- coding: utf-8 -*- from django.db import models -#from django.contrib.auth.models.User import User as UserProfile +from django.contrib.auth.models import User # Create your models here. - -class Perm(models.Model): - """ extended pyLoad user Profile """ - - #user = models.ForeignKey(UserProfile, unique=True) - #template = models.CharField(maxlength=30) +class UserProfile(models.Model): + """ Permissions setting """ - class Meta: - permissions = ( - ("can_see_dl", "Can see Downloads"), - ("can_add", "Can add Downloads"), - ("can_delete", "Can delete Downloads"), - ("can_download", "Can download Files"), - ("can_see_logs", "Can see logs"), - ("can_change_status", "Can change status"), - )
\ No newline at end of file + user = models.ForeignKey(User, unique=True) + template = models.CharField(max_length=30, default='default', null=False, blank=False) + +def user_post_save(sender, instance, **kwargs): + profile, new = UserProfile.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/urls.py b/module/web/pyload/urls.py index 9c7942492..667a4ed3d 100644 --- a/module/web/pyload/urls.py +++ b/module/web/pyload/urls.py @@ -1,7 +1,19 @@ + +from os.path import join + +from django.conf import settings from django.conf.urls.defaults import * -urlpatterns = patterns('', - (r'^login/$', 'pyload.views.login'), - (r'^home/$', 'pyload.views.home'), - (r'^test/$', 'pyload.views.home'), -) + +urlpatterns = patterns('pyload', + (r'^home/$', 'views.home'), + (r'^downloads/$', 'views.downloads',{},'downloads'), + (r'^queue/$', 'views.queue',{}, 'queue'), + (r'^logs/$', 'views.logs',{}, 'logs'), + (r'^$', 'views.home',{}, 'home'), + ) + +urlpatterns += patterns('django.contrib.auth', + (r'^login/$', 'views.login', {'template_name': join(settings.TEMPLATE, 'login.html')}), + (r'^logout/$', 'views.logout', {'template_name': join(settings.TEMPLATE, 'logout.html')}, 'logout'), +)
\ No newline at end of file diff --git a/module/web/pyload/views.py b/module/web/pyload/views.py index c42511ede..6c2954555 100644 --- a/module/web/pyload/views.py +++ b/module/web/pyload/views.py @@ -1,7 +1,6 @@ # Create your views here. from django.http import HttpResponse from django.http import HttpResponseRedirect -from django.http import HttpResponseGone from django.conf import settings from django.shortcuts import render_to_response from django.template import RequestContext @@ -14,9 +13,9 @@ def check_server(function): def _view(request, *args, **kwargs): try: version = settings.PYLOAD.get_server_version() - return view_func(request, *args, **kwargs) except Exception, e: return base(request, messages=['Can\'t connect to pyLoad. Please check your configuration and make sure pyLoad is running.',str(e)]) + return view_func(request, *args, **kwargs) _view.__name__ = view_func.__name__ _view.__dict__ = view_func.__dict__ @@ -54,6 +53,7 @@ def base(request, messages): #@permission('perm.permissions.can_see_dl') @TODO: Permissions not working :( @check_server def home(request): + print request.user.get_all_permissions() return render_to_response(join(settings.TEMPLATE,'home.html'), RequestContext(request)) |