sample api app

This commit is contained in:
baccenfutter 2013-10-20 20:42:13 +02:00
parent 0d49874df1
commit 9eca98c1d4
6 changed files with 54 additions and 17 deletions

View file

@ -7,22 +7,23 @@
<h2>{{ request.user.username }}</h2> <h2>{{ request.user.username }}</h2>
{% for g in request.user.groups.all %} {% for g in request.user.groups.all %}
{% if g.name == "ceymaster" %} {% if g.name == "ceymaster" %}
<a href="/groups/{{ g }}"> <badge class="badge badge-important">
<label class="label label-important">{{ g }}</label> {{ g }}
</a> </badge>
{% elif "cey" in g.name %} {% elif "cey" in g.name %}
<a href="/groups/{{ g }}"> <badge class="badge badge-warning">
<label class="label label-warning">{{ g }}</label> {{ g }}
</a> </badge>
{% elif g.name == "ldap_admins" %} {% elif g.name == "ldap_admins" %}
<a href="/groups/{{ g }}"> <badge class="badge badge-success">
<label class="label label-success">{{ g }}</label> {{ g }}
</a> </badge>
{% else %} {% else %}
<a href="/groups/{{ g }}"> <badge class="badge">
<label class="label">{{ g }}</label> {{ g }}
</a> </badge>
{% endif %} {% endif %}
<br />
{% empty %} {% empty %}
no groups... no groups...
{% endfor %} {% endfor %}

0
cbapi_ldap/__init__.py Normal file
View file

9
cbapi_ldap/urls.py Normal file
View file

@ -0,0 +1,9 @@
from django.conf.urls import patterns, url
from jsonrpc import jsonrpc_site
from cbapi_ldap import views
urlpatterns = patterns(
'',
url(r'^ldap/browse/$', 'jsonrpc.views.browse', name='jsonrpc_browser'),
url(r'^ldap/$', jsonrpc_site.dispatch, name='jsonrpc_mountpoint'),
)

22
cbapi_ldap/views.py Normal file
View file

@ -0,0 +1,22 @@
from jsonrpc import jsonrpc_method
TODO = [
'',
]
@jsonrpc_method("ping", authenticated=True)
def ping(request, username, password):
"""Ping - Echo Request
:returns str: echo_response
"""
echo_response = "PONG"
return echo_response
@jsonrpc_method("todo")
def todo(request):
"""Todo - List ToDo Items
:returns list: todolist
"""
return TODO

View file

@ -165,8 +165,10 @@ INSTALLED_APPS = (
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'django.contrib.admin', 'django.contrib.admin',
'django.contrib.admindocs', 'django.contrib.admindocs',
'jsonrpc',
'cbmi', 'cbmi',
'account', 'account',
'cbapi_ldap',
) )
# A sample logging configuration. The only tangible logging # A sample logging configuration. The only tangible logging

View file

@ -6,6 +6,9 @@ admin.autodiscover()
urlpatterns = patterns('', urlpatterns = patterns('',
url(r'^admin/doc/', include('django.contrib.admindocs.urls')), url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
url(r'^admin/', include(admin.site.urls)), url(r'^admin/', include(admin.site.urls)),
url(r'^cbapi/', include("cbapi_ldap.urls")),
url(r'account/', include('account.urls')), url(r'account/', include('account.urls')),
url(r'^groups/(?P<group_name>[^/]+)/', 'cbmi.views.groups_list'), url(r'^groups/(?P<group_name>[^/]+)/', 'cbmi.views.groups_list'),
url(r'^$', 'cbmi.views.landingpage') url(r'^$', 'cbmi.views.landingpage')