diff --git a/pandora/api/actions.py b/pandora/api/actions.py index f570dad..6f5ad52 100644 --- a/pandora/api/actions.py +++ b/pandora/api/actions.py @@ -1,6 +1,24 @@ +# -*- coding: utf-8 -*- +# vi:si:et:sw=4:sts=4:ts=4 import sys -from ox.django.shortcuts import render_to_json_response, get_object_or_404_json, json_response +from django.conf import settings + +from ox.django.shortcuts import render_to_json_response, json_response + + +def autodiscover(): + #register api actions from all installed apps + from django.utils.importlib import import_module + from django.utils.module_loading import module_has_submodule + for app in settings.INSTALLED_APPS: + if app != 'api': + mod = import_module(app) + try: + import_module('%s.views'%app) + except: + if module_has_submodule(mod, 'views'): + raise def trim(docstring): @@ -28,7 +46,6 @@ def trim(docstring): # Return a single string: return '\n'.join(trimmed) - class ApiActions(dict): def __init__(self): def api(request): diff --git a/pandora/api/views.py b/pandora/api/views.py index 49834bc..028ff1b 100644 --- a/pandora/api/views.py +++ b/pandora/api/views.py @@ -33,18 +33,6 @@ from pandora.archive import extract from actions import actions -#register all api actions -from django.utils.importlib import import_module -from django.utils.module_loading import module_has_submodule -for app in settings.INSTALLED_APPS: - if app != 'api': - mod = import_module(app) - try: - import_module('%s.views'%app) - except: - if module_has_submodule(mod, 'views'): - raise - def api(request): if request.META['REQUEST_METHOD'] == "OPTIONS": response = HttpResponse('') diff --git a/pandora/archive/models.py b/pandora/archive/models.py index ffbc7b6..f4206eb 100644 --- a/pandora/archive/models.py +++ b/pandora/archive/models.py @@ -5,7 +5,6 @@ from datetime import datetime import os.path import random import re -from decimal import Decimal import time from django.db import models @@ -28,13 +27,6 @@ from item.models import Item import extract -def parse_decimal(string): - string = string.replace(':', '/') - if '/' not in string: - string = '%s/1' % string - d = string.split('/') - return Decimal(d[0]) / Decimal(d[1]) - class File(models.Model): created = models.DateTimeField(auto_now_add=True) modified = models.DateTimeField(auto_now=True) @@ -117,7 +109,7 @@ class File(models.Model): self.is_audio = False if self.framerate: - self.pixels = int(self.width * self.height * float(parse_decimal(self.framerate)) * self.duration) + self.pixels = int(self.width * self.height * float(utils.parse_decimal(self.framerate)) * self.duration) if not self.is_audio and not self.is_video and self.name.endswith('.srt'): self.is_subtitle = True diff --git a/pandora/item/utils.py b/pandora/item/utils.py index 989bae7..9eb378b 100644 --- a/pandora/item/utils.py +++ b/pandora/item/utils.py @@ -3,6 +3,7 @@ # vi:si:et:sw=4:sts=4:ts=4 # import errno +from decimal import Decimal import os import sys import re @@ -14,6 +15,13 @@ import ox.iso from ox.normalize import normalizeName, normalizeTitle, canonicalTitle +def parse_decimal(string): + string = string.replace(':', '/') + if '/' not in string: + string = '%s/1' % string + d = string.split('/') + return Decimal(d[0]) / Decimal(d[1]) + def plural_key(term): return { 'country': 'countries', diff --git a/pandora/settings.py b/pandora/settings.py index c2312c3..3314ad4 100644 --- a/pandora/settings.py +++ b/pandora/settings.py @@ -157,6 +157,17 @@ TRANSMISSON_USER = 'transmission' TRANSMISSON_PASSWORD = 'transmission' +#Movie related settings +REVIEW_WHITELIST = { + u'filmcritic.com': u'Filmcritic', + u'metacritic.com': u'Metacritic', + u'nytimes.com': u'New York Times', + u'rottentomatoes.com': u'Rotten Tomatoes', + u'salon.com': u'Salon.com', + u'sensesofcinema.com': u'Senses of Cinema', + u'villagevoice.com': u'Village Voice' +} + #list of poster services, https://wiki.0x2620.org/wiki/pandora/posterservice POSTER_SERVICES = [] POSTER_PRECEDENCE = ( @@ -170,16 +181,6 @@ POSTER_PRECEDENCE = ( 'other' ) -REVIEW_WHITELIST = { - u'filmcritic.com': u'Filmcritic', - u'metacritic.com': u'Metacritic', - u'nytimes.com': u'New York Times', - u'rottentomatoes.com': u'Rotten Tomatoes', - u'salon.com': u'Salon.com', - u'sensesofcinema.com': u'Senses of Cinema', - u'villagevoice.com': u'Village Voice' -} - #0xdb.org #POSTER_SERVICES=['http://data.0xdb.org/poster/'] diff --git a/pandora/urls.py b/pandora/urls.py index c2d30e0..c178926 100644 --- a/pandora/urls.py +++ b/pandora/urls.py @@ -11,6 +11,8 @@ from django.conf import settings from django.contrib import admin admin.autodiscover() +from api import actions +actions.autodiscover() def serve_static_file(path, location, content_type): return HttpFileResponse(location, content_type=content_type) diff --git a/pandora/user/views.py b/pandora/user/views.py index 60b9117..166e733 100644 --- a/pandora/user/views.py +++ b/pandora/user/views.py @@ -170,6 +170,9 @@ def findUser(request): actions.register(findUser) def recover(request, key): + ''' + recover user and redirect to settings + ''' qs = models.UserProfile.objects.filter(recover_key=key) if qs.count() == 1: user = qs[0].user