-
-
Save enko/778706 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def manage(request): | |
if (request.action == 'new_entry'): | |
result = new_entry(request) | |
render(request.format,result) | |
if (request.action == 'new_pin'): | |
result = new_pin(request) | |
render(request.format,result) | |
def render(format,obj): | |
if (format == 'json'): | |
render_json(obj) | |
if (format == 'xml'): | |
render_xml(obj) | |
def new_entry(request): | |
if ('submit' in request.POST): | |
# gives us a json: { "text" : "Dies ist eine Meldung", "isPublic" : 1 } | |
# entry_text = | |
# entry_isPublic = | |
# entry_published = datetime.now() | |
# -> save | |
# return a python object | |
def new_pin(request): | |
if ('submit' in request.POST): | |
# { "pin" : "123456" } | |
# pin_value = | |
# return a python object | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding=utf-8 | |
from django.conf.urls.defaults import * | |
# Uncomment the next two lines to enable the admin: | |
from django.contrib import admin | |
admin.autodiscover() | |
urlpatterns = patterns('', | |
# Example: | |
# (r'^Ticker/', include('Ticker.foo.urls')), | |
(r'^$', 'Ticker.frontend.views.index'), | |
(r'^(?P<pin>\d+)/$', 'Ticker.frontend.views.index'), | |
(r'^manage/$', 'Ticker.frontend.views.manage'), | |
# dont know if this works but I have someting like this wuold be cool: | |
(r'^manage/(?P<action>(.+?))(?P<format>\:(.+?)$', 'Ticker.frontend.views.manage'), | |
(r'^accounts/login/$', 'Ticker.frontend.views.login'), | |
(r'^accounts/logout/$', 'Ticker.frontend.views.logout'), | |
# Uncomment the admin/doc line below and add 'django.contrib.admindocs' | |
# to INSTALLED_APPS to enable admin documentation: | |
# (r'^admin/doc/', include('django.contrib.admindocs.urls')), | |
# Uncomment the next line to enable the admin: | |
(r'^admin/', include(admin.site.urls)), | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment