Commit 1d072fb7 authored by Georgios Gousios's avatar Georgios Gousios
Browse files

Methods to retrieve list of active synnefo users

parent 272dca5e
# vim: set fileencoding=utf-8 :
# Copyright 2011 GRNET S.A. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# The views and conclusions contained in the software and documentation are
# those of the authors and should not be interpreted as representing official
# policies, either expressed or implied, of GRNET S.A.
from django.views.decorators.csrf import csrf_protect
from django.template.loader import render_to_string
from django.template.context import RequestContext
from django.http import HttpResponse
from synnefo.db.models import SynnefoUser, Invitations
from synnefo.api.common import method_not_allowed
@csrf_protect
def index(request):
if request.method == 'GET':
data = render_to_string('helpdesk.html',
{'users': get_users(request)},
context_instance=RequestContext(request))
return HttpResponse(data)
else:
method_not_allowed(request)
def get_users(request):
#XXX: The following filter should change when the invitations app is removed
invitations = Invitations.objects.filter(accepted = False)
ids = map(lambda x: x.target.id, invitations)
users = SynnefoUser.objects.exclude(id__in = ids).order_by('realname')
result = []
for user in users:
resultentry = {}
resultentry['id'] = user.id
resultentry['name'] = user.realname
result.append(resultentry)
return result
def get_tmp_token(request):
pass
\ No newline at end of file
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Σύννεφο -- Εφαρμογή HelpDesk</title>
<script src="/static/jquery.tools.min.js"></script>
<style>
.center {text-align: center;}
.header {height: 10%;}
.frame {width: 100%; height: 90%}
</style>
<script type="text/javascript">
$(document).ready(function() {
$("#go").
$.ajax({
url: '/helpdesk/token',
type: 'POST',
success: function(data) {
},
error : function() {
}
});
});
</script>
</head>
<body>
<div id="header" class="center">
Επιλέξτε το όνομα του χρήστη:
<select id="username">
<option value="">--Επιλογή--</option>
{% for user in users %}
<option value="{{ user.id }}">{{ user.name }}</option>
{% endfor %}
</select>
<input id="go" type="button" value="Go"/>
</div>
<iframe id="content" src="/" class="center frame">
<p>
Your browser does not support iframes.
Use a current millenium browser.
</p>
</iframe>
</body>
</html>
\ No newline at end of file
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Σύννεφο -- Εφαρμογή HelpDesk </title>
</head>
<body>
<div id="header">
Επιλέξτε το όνομα του χρήστη:
<select id="username">
<option value="">--Επιλέξτε χρήστη--</option>
{% for user in users %}
<option value="{{ user.id }}">{{ user.name }}</option>
{% endfor %}
</select>
<input type="button" value="Go"/>
</div>
<iframe id="content" src="">
<p>Your browser does not support iframes. Use a current millenium browser.</p>
</iframe>
</body>
</html>
\ No newline at end of file
......@@ -2,5 +2,6 @@ from django.conf.urls.defaults import *
import os
urlpatterns = patterns('',
(r'^$', 'synnefo.helpdesk.helpdesk.index'),
(r'^/token$', 'synnefo.helpdesk.helpdesk.get_tmp_token'),
)
......@@ -28,6 +28,8 @@ def process_form(request):
for inv in valid_inv:
(name, inv_id) = inv.split('_')
email = ""
name = ""
try:
email = request.POST['email_' + inv_id]
name = request.POST[inv]
......
......@@ -133,6 +133,7 @@ INSTALLED_APPS = (
'synnefo.ganeti',
'synnefo.logic',
'synnefo.invitations',
'synnefo.helpdesk',
'south'
)
......
......@@ -15,4 +15,5 @@ urlpatterns = patterns('',
(r'^', include('synnefo.ui.urls')),
(r'^admin/', include(admin.site.urls)),
(r'^invitations/?', include('synnefo.invitations.urls')),
(r'^helpdesk/?', include('synnefo.helpdesk.urls')),
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment