From 139af81833f2b6727618d8e2c30cc7157c42e8a1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C5=81ukasz=20Anwajler?= Date: Thu, 24 Feb 2011 11:15:57 +0100 Subject: [PATCH 1/1] missing files --- apps/api/handlers.py | 2 +- apps/api/urls.py | 2 +- apps/api/views.py | 10 ++++ apps/catalogue/views.py | 54 +++++++++++++------ .../templates/piston/authorize_token.html | 2 +- wolnelektury/static/css/mobile.css | 7 +++ wolnelektury/templates/auth/login.html | 2 +- wolnelektury/urls.py | 1 + 8 files changed, 61 insertions(+), 19 deletions(-) create mode 100644 apps/api/views.py create mode 100644 wolnelektury/static/css/mobile.css diff --git a/apps/api/handlers.py b/apps/api/handlers.py index ac47ac60d..151af2d28 100644 --- a/apps/api/handlers.py +++ b/apps/api/handlers.py @@ -52,4 +52,4 @@ class BookHandler(BaseHandler): return rc.CREATED else: return rc.BAD_REQUEST -""" \ No newline at end of file +""" diff --git a/apps/api/urls.py b/apps/api/urls.py index 5fade25ba..beb4a7b01 100644 --- a/apps/api/urls.py +++ b/apps/api/urls.py @@ -24,4 +24,4 @@ urlpatterns += patterns( url(r'^oauth/request_token/$','oauth_request_token'), url(r'^oauth/authorize/$','oauth_user_auth'), url(r'^oauth/access_token/$','oauth_access_token'), -) \ No newline at end of file +) diff --git a/apps/api/views.py b/apps/api/views.py new file mode 100644 index 000000000..1c5e84834 --- /dev/null +++ b/apps/api/views.py @@ -0,0 +1,10 @@ +from django.http import HttpResponseRedirect + +def oauth_callback(request, data): + key = data.key + secret = data.secret + verifier = data.verifier + timestamp = data.timestamp + print data + return HttpResponseRedirect("wl://") + #return HttpResponseRedirect("wl://%s/%s/%s/%s/" % (key, secret, verifier, timestamp)) diff --git a/apps/catalogue/views.py b/apps/catalogue/views.py index 7f1de6d46..5de0e9dc2 100644 --- a/apps/catalogue/views.py +++ b/apps/catalogue/views.py @@ -141,7 +141,7 @@ def differentiate_tags(request, tags, ambiguous_slugs): context_instance=RequestContext(request)) -def tagged_object_list(request, tags=''): +def tagged_object_list(request, tags='', api=False): try: tags = models.Tag.get_tag_list(tags) except models.Tag.DoesNotExist: @@ -222,20 +222,23 @@ def tagged_object_list(request, tags=''): only_author = len(tags) == 1 and tags[0].category == 'author' objects = models.Book.objects.none() - return object_list( - request, - objects, - template_name='catalogue/tagged_object_list.html', - extra_context={ - 'categories': categories, - 'only_shelf': only_shelf, - 'only_author': only_author, - 'only_my_shelf': only_my_shelf, - 'formats_form': forms.DownloadFormatsForm(), - - 'tags': tags, - } - ) + if api: + print objects + return objects + else: + return object_list( + request, + objects, + template_name='catalogue/tagged_object_list.html', + extra_context={ + 'categories': categories, + 'only_shelf': only_shelf, + 'only_author': only_author, + 'only_my_shelf': only_my_shelf, + 'formats_form': forms.DownloadFormatsForm(), + 'tags': tags, + } + ) def book_fragments(request, book_slug, theme_slug): @@ -680,6 +683,27 @@ def delete_shelf(request, slug): # ================== # = Authentication = # ================== + +@cache.never_cache +def simple_login(request): + if request.method == "GET": + #next = request.REQUEST.get('next', '') + #if next == '': + form = AuthenticationForm(prefix='login') + return render_to_response('auth/login.html', locals(), + context_instance=RequestContext(request)) + #else: + # return HttpResponseRedirect("/"+next) + + elif request.method == "POST": + form = AuthenticationForm(data=request.POST, prefix='login') + if form.is_valid(): + auth.login(request, form.get_user()) + url = request.META['HTTP_REFERER'].split("next=")[1] + url = url.replace("%3F","?").replace("%3D","=") + return HttpResponseRedirect(url) + + @require_POST @cache.never_cache def login(request): diff --git a/apps/piston/templates/piston/authorize_token.html b/apps/piston/templates/piston/authorize_token.html index d3ec588e4..3507e55f8 100644 --- a/apps/piston/templates/piston/authorize_token.html +++ b/apps/piston/templates/piston/authorize_token.html @@ -14,4 +14,4 @@ - \ No newline at end of file + diff --git a/wolnelektury/static/css/mobile.css b/wolnelektury/static/css/mobile.css new file mode 100644 index 000000000..2f04e6596 --- /dev/null +++ b/wolnelektury/static/css/mobile.css @@ -0,0 +1,7 @@ +ul li { + list-style-type: none; +} + +h1 { + font-size: 1em; +} diff --git a/wolnelektury/templates/auth/login.html b/wolnelektury/templates/auth/login.html index d3cf660dd..204cce641 100644 --- a/wolnelektury/templates/auth/login.html +++ b/wolnelektury/templates/auth/login.html @@ -25,4 +25,4 @@ - \ No newline at end of file + diff --git a/wolnelektury/urls.py b/wolnelektury/urls.py index 53e6429f2..0d61a3611 100644 --- a/wolnelektury/urls.py +++ b/wolnelektury/urls.py @@ -36,6 +36,7 @@ urlpatterns = patterns('', url(r'^admin/', include(admin.site.urls)), # Authentication + url(r'^users/simple_login/$', 'catalogue.views.simple_login', name='simple_login'), url(r'^uzytkownicy/zaloguj/$', 'catalogue.views.login', name='login'), url(r'^uzytkownicy/wyloguj/$', 'catalogue.views.logout_then_redirect', name='logout'), url(r'^uzytkownicy/utworz/$', 'catalogue.views.register', name='register'), -- 2.20.1