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>
{% for g in request.user.groups.all %}
{% if g.name == "ceymaster" %}
<a href="/groups/{{ g }}">
<label class="label label-important">{{ g }}</label>
</a>
<badge class="badge badge-important">
{{ g }}
</badge>
{% elif "cey" in g.name %}
<a href="/groups/{{ g }}">
<label class="label label-warning">{{ g }}</label>
</a>
<badge class="badge badge-warning">
{{ g }}
</badge>
{% elif g.name == "ldap_admins" %}
<a href="/groups/{{ g }}">
<label class="label label-success">{{ g }}</label>
</a>
<badge class="badge badge-success">
{{ g }}
</badge>
{% else %}
<a href="/groups/{{ g }}">
<label class="label">{{ g }}</label>
</a>
<badge class="badge">
{{ g }}
</badge>
{% endif %}
<br />
{% empty %}
no groups...
{% 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.admin',
'django.contrib.admindocs',
'jsonrpc',
'cbmi',
'account',
'cbapi_ldap',
)
# A sample logging configuration. The only tangible logging

View file

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