added user list and ability for staff to create speaker profiles
This commit is contained in:
parent
9e794bd66a
commit
347617ead3
6 changed files with 166 additions and 31 deletions
6
symposion/conference/urls.py
Normal file
6
symposion/conference/urls.py
Normal file
|
@ -0,0 +1,6 @@
|
|||
from django.conf.urls.defaults import *
|
||||
|
||||
|
||||
urlpatterns = patterns("symposion.conference.views",
|
||||
url(r"^users/$", "user_list", name="user_list"),
|
||||
)
|
16
symposion/conference/views.py
Normal file
16
symposion/conference/views.py
Normal file
|
@ -0,0 +1,16 @@
|
|||
from django.http import Http404
|
||||
from django.shortcuts import render
|
||||
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
|
||||
@login_required
|
||||
def user_list(request):
|
||||
|
||||
if not request.user.is_staff:
|
||||
raise Http404()
|
||||
|
||||
return render(request, "conference/user_list.html", {
|
||||
"users": User.objects.all(),
|
||||
})
|
|
@ -6,4 +6,5 @@ urlpatterns = patterns("symposion.speakers.views",
|
|||
url(r"^create/(\w+)/$", "speaker_create_token", name="speaker_create_token"),
|
||||
url(r"^edit/(?:(?P<pk>\d+)/)?$", "speaker_edit", name="speaker_edit"),
|
||||
url(r"^profile/(?P<pk>\d+)/$", "speaker_profile", name="speaker_profile"),
|
||||
url(r"^staff/create/(\w+)/$", "speaker_create_staff", name="speaker_create_staff"),
|
||||
)
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
from django.conf import settings
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from django.db.models import Q
|
||||
from django.http import Http404, HttpResponse
|
||||
from django.http import Http404
|
||||
from django.shortcuts import render, redirect, get_object_or_404
|
||||
from django.template import RequestContext
|
||||
|
||||
from django.contrib import messages
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
from symposion.proposals.models import ProposalBase
|
||||
from symposion.speakers.forms import SpeakerForm #, SignupForm
|
||||
from symposion.speakers.forms import SpeakerForm
|
||||
from symposion.speakers.models import Speaker
|
||||
|
||||
|
||||
|
@ -38,10 +36,38 @@ def speaker_create(request):
|
|||
messages.success(request, "Speaker profile created.")
|
||||
return redirect("dashboard")
|
||||
else:
|
||||
form = SpeakerForm(initial = {"name": request.user.get_full_name()})
|
||||
form = SpeakerForm(initial={"name": request.user.get_full_name()})
|
||||
|
||||
return render(request, "speakers/speaker_create.html", {
|
||||
"form": form,
|
||||
"form": form,
|
||||
})
|
||||
|
||||
|
||||
@login_required
|
||||
def speaker_create_staff(request, username):
|
||||
user = get_object_or_404(User, username=username)
|
||||
if not request.user.is_staff:
|
||||
raise Http404
|
||||
|
||||
try:
|
||||
return redirect(user.speaker_profile)
|
||||
except ObjectDoesNotExist:
|
||||
pass
|
||||
|
||||
if request.method == "POST":
|
||||
form = SpeakerForm(request.POST, request.FILES)
|
||||
|
||||
if form.is_valid():
|
||||
speaker = form.save(commit=False)
|
||||
speaker.user = user
|
||||
speaker.save()
|
||||
messages.success(request, "Speaker profile created.")
|
||||
return redirect("user_list")
|
||||
else:
|
||||
form = SpeakerForm(initial={"name": user.get_full_name()})
|
||||
|
||||
return render(request, "speakers/speaker_create.html", {
|
||||
"form": form,
|
||||
})
|
||||
|
||||
|
||||
|
@ -58,9 +84,9 @@ def speaker_create_token(request, token):
|
|||
del request.session["pending-token"]
|
||||
additional_speakers = ProposalBase.additional_speakers.through
|
||||
additional_speakers._default_manager.filter(
|
||||
speaker = speaker
|
||||
speaker=speaker
|
||||
).update(
|
||||
speaker = existing_speaker
|
||||
speaker=existing_speaker
|
||||
)
|
||||
messages.info(request, "You have been associated with all pending "
|
||||
"talk proposals")
|
||||
|
|
106
symposion/templates/conference/user_list.html
Normal file
106
symposion/templates/conference/user_list.html
Normal file
|
@ -0,0 +1,106 @@
|
|||
{% extends "site_base.html" %}
|
||||
|
||||
{% load i18n %}
|
||||
{% load sitetree %}
|
||||
|
||||
{% block head_title %}User List{% endblock %}
|
||||
|
||||
{% block extra_style %}
|
||||
<style type="text/css">
|
||||
div.dataTables_length label {
|
||||
float: left;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
div.dataTables_length select {
|
||||
width: 75px;
|
||||
}
|
||||
|
||||
div.dataTables_filter label {
|
||||
float: right;
|
||||
}
|
||||
|
||||
div.dataTables_info {
|
||||
padding-top: 8px;
|
||||
}
|
||||
|
||||
div.dataTables_paginate {
|
||||
float: right;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
table.table {
|
||||
clear: both;
|
||||
margin-bottom: 6px !important;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
table.table thead .sorting,
|
||||
table.table thead .sorting_asc,
|
||||
table.table thead .sorting_desc,
|
||||
table.table thead .sorting_asc_disabled,
|
||||
table.table thead .sorting_desc_disabled {
|
||||
cursor: pointer;
|
||||
*cursor: hand;
|
||||
}
|
||||
|
||||
table.dataTable th:active {
|
||||
outline: none;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
{% block body_outer %}
|
||||
<div class="row">
|
||||
<div class="span12">
|
||||
<h1>User List</h1>
|
||||
<table class="table table-striped table-bordered table-reviews">
|
||||
<thead>
|
||||
<th>{% trans "Email" %}</th>
|
||||
<th>{% trans "Name" %}</th>
|
||||
<th>{% trans "Speaker Profile?" %}</th>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
{% for user in users %}
|
||||
<tr>
|
||||
<td>{{ user.email }}</td>
|
||||
<td>{{ user.get_full_name }}</td>
|
||||
<td>
|
||||
{% if user.speaker_profile %}
|
||||
<a href="{% url speaker_profile user.speaker_profile.pk %}">{{ user.speaker_profile }}</a>
|
||||
{% else %}
|
||||
<a href="{% url speaker_create_staff user.username %}" class="btn btn-mini">create</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_script %}
|
||||
<script src="{{ STATIC_URL }}datatables/js/jquery.dataTables.min.js" type="text/javascript"></script>
|
||||
<script src="{{ STATIC_URL }}tabletools/js/TableTools.min.js" type="text/javascript"></script>
|
||||
<script src="{{ STATIC_URL }}datatables/js/dataTables.bootstrap.js" type="text/javascript"></script>
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
$(".tip").tooltip();
|
||||
$("table.table-reviews").dataTable({
|
||||
"sDom": "<'row'<'span3'l><'span3'T><'span4'f>r>t<'row'<'span3'i><'span5'p>>",
|
||||
"sPaginationType": "bootstrap",
|
||||
"bStateSave": true,
|
||||
"oTableTools": {
|
||||
"aButtons": [
|
||||
"copy",
|
||||
"csv",
|
||||
"print"
|
||||
],
|
||||
"sSwfPath": "{{ STATIC_URL }}tabletools/swf/copy_csv_xls.swf"
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
|
@ -11,6 +11,8 @@
|
|||
<div class="span2">
|
||||
{% if speaker.photo %}
|
||||
<img src="{% thumbnail speaker.photo '128x128' %}" alt="{{ speaker.name }}" />
|
||||
{% else %}
|
||||
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="span6">
|
||||
|
@ -36,26 +38,4 @@
|
|||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
||||
|
||||
|
||||
{% comment %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
{% if sessions %}
|
||||
<h3>Presentations</h3>
|
||||
|
||||
<dl class="sessions">
|
||||
{% for session in sessions %}
|
||||
<dt>{{ session.slot.start|localtime:timezone|date:"F jS" }} {{ session.slot.start|localtime:timezone|date:"P" }} – {{ session.slot.end|localtime:timezone|date:"P" }}</dt>
|
||||
<dd><a href="{% url schedule_presentation session.id %}">{{ session.title }}</a></dd>
|
||||
{% endfor %}
|
||||
</dl>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% endcomment %}
|
Loading…
Reference in a new issue