# Path: bundestagger/account/openid_consumer.py
# class BundesOpenidConsumer(SessionConsumer):
#     session_key = 'openid'
#     openid_required_message = 'Gib eine OpenID ein'
#     xri_disabled_message = 'i-names werden nicht unterstützt'
#     openid_invalid_message = 'Die OpenID ist nicht gültig'
#     request_cancelled_message = 'Die Anfrage wurde abgebrochen'
#     message_loggedin = "Erfolgreich eingeloggt"
#     message_loggedout = "Erfolgreich ausgeloggt"
#     failure_message = 'Fehler: %s'
#     setup_needed_message = 'Setup benötigt'
#     sign_next_param = False
#     salt_next = '07n98kpajapd290?(H"N=)(czar3)' # Adds extra saltiness to the ?next= salt
#     xri_enabled = False
#     on_complete_url = None
#     trust_root = settings.SITE_DOMAIN # If None, full URL to endpoint is used
#     logo_path = None # Path to the OpenID logo, as used by the login view
#     
#     def show_error(self, request, message, exception=None):
#         messages.error(request, message)
#         return HttpResponseRedirect("/")
# 
#     def show_message(self, request, title, message):
#         messages.info(request, message)
#         return HttpResponseRedirect("/")
# 
#     def on_success(self, request, identity_url, openid_response):
#         messages.info(request, self.message_loggedin)
#         login(request, identity_url)
#         return super(BundesOpenidConsumer,self).on_success(request, identity_url, openid_response)
#     
#     def do_logout(self, request):
#         logout(request)
#         response =  super(BundesOpenidConsumer,self).do_logout(request)
#         messages.info(request, self.message_loggedout)
#         return response
# 
# Path: bundestagger/helper/utils.py
# def is_get(func):
#     return is_method("GET", func)


from django.conf.urls.defaults import *
from django.conf import settings
from django.contrib import admin
from django.shortcuts import render_to_response
from django.views.generic.simple import direct_to_template
from bundestagger.account.openid_consumer import BundesOpenidConsumer
from bundestagger.helper.utils import is_get


# direct to template may only be GET requests (post may be evil, caching wise)
direct_to_template = is_get(direct_to_template)

admin.autodiscover()

openid_consumer = BundesOpenidConsumer()

urlpatterns = patterns('',
    (r'^$', direct_to_template, {"template": "index.html"}, "bundestagger-index"), 
    (r'^impressum/$', direct_to_template, {"template": "impressum.html"}, "bundestagger-impressum"),
    (r'^informationen/$', direct_to_template, {"template": "informationen.html"}, "bundestagger-informationen"),
    (r'^api/$', direct_to_template, {"template": "api.html"}, "bundestagger-api"),
    (r'^nutzungsbedingungen-datenschutz/$', direct_to_template, {"template": "terms.html"}, "bundestagger-terms"),

# Path: bundestagger/account/openid_consumer.py
# class BundesOpenidConsumer(SessionConsumer):
#     session_key = 'openid'
#     openid_required_message = 'Gib eine OpenID ein'
#     xri_disabled_message = 'i-names werden nicht unterstützt'
#     openid_invalid_message = 'Die OpenID ist nicht gültig'
#     request_cancelled_message = 'Die Anfrage wurde abgebrochen'
#     message_loggedin = "Erfolgreich eingeloggt"
#     message_loggedout = "Erfolgreich ausgeloggt"
#     failure_message = 'Fehler: %s'
#     setup_needed_message = 'Setup benötigt'
#     sign_next_param = False
#     salt_next = '07n98kpajapd290?(H"N=)(czar3)' # Adds extra saltiness to the ?next= salt
#     xri_enabled = False
#     on_complete_url = None
#     trust_root = settings.SITE_DOMAIN # If None, full URL to endpoint is used
#     logo_path = None # Path to the OpenID logo, as used by the login view
#     
#     def show_error(self, request, message, exception=None):
#         messages.error(request, message)
#         return HttpResponseRedirect("/")
# 
#     def show_message(self, request, title, message):
#         messages.info(request, message)
#         return HttpResponseRedirect("/")
# 
#     def on_success(self, request, identity_url, openid_response):
#         messages.info(request, self.message_loggedin)
#         login(request, identity_url)
#         return super(BundesOpenidConsumer,self).on_success(request, identity_url, openid_response)
#     
#     def do_logout(self, request):
#         logout(request)
#         response =  super(BundesOpenidConsumer,self).do_logout(request)
#         messages.info(request, self.message_loggedout)
#         return response
# 
# Path: bundestagger/helper/utils.py
# def is_get(func):
#     return is_method("GET", func)


# Path: bundestagger/urls.py
from django.conf.urls.defaults import *
from django.conf import settings
from django.contrib import admin
from django.shortcuts import render_to_response
from django.views.generic.simple import direct_to_template
from bundestagger.account.openid_consumer import BundesOpenidConsumer
from bundestagger.helper.utils import is_get



# direct to template may only be GET requests (post may be evil, caching wise)
direct_to_template = is_get(direct_to_template)

admin.autodiscover()

openid_consumer = BundesOpenidConsumer()

urlpatterns = patterns('',
    (r'^$', direct_to_template, {"template": "index.html"}, "bundestagger-index"), 
    (r'^impressum/$', direct_to_template, {"template": "impressum.html"}, "bundestagger-impressum"),
    (r'^informationen/$', direct_to_template, {"template": "informationen.html"}, "bundestagger-informationen"),
    (r'^api/$', direct_to_template, {"template": "api.html"}, "bundestagger-api"),
    (r'^nutzungsbedingungen-datenschutz/$', direct_to_template, {"template": "terms.html"}, "bundestagger-terms"),

    (r'^webtv/config/(?P<id>\d+)/$', direct_to_template, {"template": "bundestag/config.xml"}, "bundestagger-webtvconfig"),