diff options
Diffstat (limited to 'module')
-rw-r--r-- | module/web/ajax/views.py | 33 | ||||
-rw-r--r-- | module/web/pyload.db | bin | 34816 -> 39936 bytes | |||
-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 | ||||
-rw-r--r-- | module/web/templates/default/base.html | 10 | ||||
-rw-r--r-- | module/web/templates/default/home.html | 6 | ||||
-rw-r--r-- | module/web/urls.py | 2 |
8 files changed, 61 insertions, 25 deletions
diff --git a/module/web/ajax/views.py b/module/web/ajax/views.py index d883376e7..c4395a659 100644 --- a/module/web/ajax/views.py +++ b/module/web/ajax/views.py @@ -12,9 +12,10 @@ 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 HttpResponseServerError() + + return view_func(request, *args, **kwargs) _view.__name__ = view_func.__name__ _view.__dict__ = view_func.__dict__ @@ -30,7 +31,7 @@ def check_server(function): def permission(perm): def _dec(view_func): def _view(request, *args, **kwargs): - if request.user.has_perm(perm) and request.user.is_authenticated: + if request.user.has_perm(perm) and request.user.is_authenticated(): return view_func(request, *args, **kwargs) else: return HttpResponseForbidden() @@ -57,14 +58,26 @@ class JsonResponse(HttpResponse): def add_package(request): a = {'b' : [1,2,3], 'dsfsd' : "sadd"} return JsonResponse(a) - -# @TODO: Auth + Auth - + + +@permission('pyload.can_see_dl') def status(request): - return JsonResponse(settings.PYLOAD.status_server()) - + try: + return JsonResponse(settings.PYLOAD.status_server()) + except: + return HttpResponseServerError() + +@permission('pyload.can_see_dl') def links(request): - return JsonResponse(settings.PYLOAD.status_downloads()) - + try: + return JsonResponse(settings.PYLOAD.status_downloads()) + except: + return HttpResponseServerError() + +@permission('pyload.can_see_dl') def queue(request): - return JsonResponse(settings.PYLOAD.get_queue())
\ No newline at end of file + try: + return JsonResponse(settings.PYLOAD.get_queue()) + + except: + return HttpResponseServerError()
\ No newline at end of file diff --git a/module/web/pyload.db b/module/web/pyload.db Binary files differindex 45f55284e..08a6dbcaf 100644 --- a/module/web/pyload.db +++ b/module/web/pyload.db 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)) diff --git a/module/web/templates/default/base.html b/module/web/templates/default/base.html index 9095d802a..5d79e8b6a 100644 --- a/module/web/templates/default/base.html +++ b/module/web/templates/default/base.html @@ -12,7 +12,7 @@ <title>{% block title %}pyLoad Webinterface{% endblock %}</title>
<script type="text/javascript">
$(document).ready(function(){
- $.getJSON('/json/statuss', LoadJsonToContent );
+ $.getJSON('/json/status', LoadJsonToContent );
});
</script>
</head>
@@ -63,23 +63,27 @@ $(document).ready(function(){ <div style="clear:both;"></div>
</div>
+{% if perms.pyload.can_change_status %}
<ul id="page-actions2">
<li><a href="" class="action play" accesskey="o" rel="nofollow">Play</a></li>
<li><a href="" class="action pause" accesskey="o" rel="nofollow">Pause</a></li>
</ul>
+{% endif %}
+{% if perms.pyload.can_see_dl %}
<ul id="page-actions">
<li><a href="" class="action backlink" accesskey="o" rel="nofollow">Speed: <b id="speed">485</b> kb/s</a></li>
<li><a href="" class="action cog" accesskey="o" rel="nofollow">Aktiv: <b id="aktiv">1</b> / <b id="aktiv_from">4</b></a></li>
<li><a href="" class="action revisions" accesskey="o" rel="nofollow">Reload page</a></li>
</ul>
+{% endif %}
-<!--div id="body-wrapper" class="dokuwiki">
+<div id="body-wrapper" class="dokuwiki">
<div id="content" lang="en" dir="ltr">
<h1><a name="pyload_download_manager_for_1_click_hoster" id="pyload_download_manager_for_1_click_hoster">pyLoad — Webinterface</a>
-</h1-->
+</h1
{% block statusbar %}
{% endblock %}
diff --git a/module/web/templates/default/home.html b/module/web/templates/default/home.html index 895302e61..40f124712 100644 --- a/module/web/templates/default/home.html +++ b/module/web/templates/default/home.html @@ -1 +1,5 @@ -{% extends 'default/base.html' %}
\ No newline at end of file +{% extends 'default/base.html' %} + +{% block content %} + +{% endblock %}
\ No newline at end of file diff --git a/module/web/urls.py b/module/web/urls.py index 6bec8dfba..3d3295efd 100644 --- a/module/web/urls.py +++ b/module/web/urls.py @@ -14,7 +14,7 @@ urlpatterns = patterns('', # to INSTALLED_APPS to enable admin documentation: # (r'^admin/doc/', include('django.contrib.admindocs.urls')), - # (r'^admin/', include(admin.site.urls)), + # (r'^admin/', include(admin.site.urls)), # django 1.0 not working (r'^json/', include('ajax.urls')), (r'^favicon\.ico$', 'django.views.generic.simple.redirect_to', {'url': '/media/img/favicon.ico'}), (r'^media/(?P<path>.*)$', 'django.views.static.serve', |