[open-ils-commits] r145 - in servres/trunk/conifer: . static syrup templates templates/components (gfawcett)
svn at svn.open-ils.org
svn at svn.open-ils.org
Sat Mar 7 20:49:34 EST 2009
Author: gfawcett
Date: 2009-03-07 20:49:33 -0500 (Sat, 07 Mar 2009)
New Revision: 145
Modified:
servres/trunk/conifer/genshi_namespace.py
servres/trunk/conifer/static/main.css
servres/trunk/conifer/syrup/urls.py
servres/trunk/conifer/syrup/views.py
servres/trunk/conifer/templates/add_new_course.xhtml
servres/trunk/conifer/templates/components/course.xhtml
servres/trunk/conifer/templates/course_detail.xhtml
Log:
UI support for editing course details
Modified: servres/trunk/conifer/genshi_namespace.py
===================================================================
--- servres/trunk/conifer/genshi_namespace.py 2009-03-08 01:49:15 UTC (rev 144)
+++ servres/trunk/conifer/genshi_namespace.py 2009-03-08 01:49:33 UTC (rev 145)
@@ -17,3 +17,12 @@
return obj() or dflt
else:
return obj or dflt
+
+
+def instructs(user, course):
+ try:
+ mbr = models.Member.objects.get(user=user, course=course)
+ return mbr.role in ('INSTR', 'PROXY')
+ except:
+ return False
+
Modified: servres/trunk/conifer/static/main.css
===================================================================
--- servres/trunk/conifer/static/main.css 2009-03-08 01:49:15 UTC (rev 144)
+++ servres/trunk/conifer/static/main.css 2009-03-08 01:49:33 UTC (rev 145)
@@ -192,6 +192,8 @@
#coursebanner h1 { padding: 0; font-size: 110%; }
+#edit_course_link { float: right; margin: 4 0 0 0; font-size: 95%; }
+
.breadcrumbs { margin: 8 8 8 0; }
.errorlist { float: right; }
@@ -205,4 +207,5 @@
text-align: left;
font-size: 90%;
font-weight: normal;
-}
\ No newline at end of file
+}
+
Modified: servres/trunk/conifer/syrup/urls.py
===================================================================
--- servres/trunk/conifer/syrup/urls.py 2009-03-08 01:49:15 UTC (rev 144)
+++ servres/trunk/conifer/syrup/urls.py 2009-03-08 01:49:33 UTC (rev 145)
@@ -21,6 +21,7 @@
(r'^instructor/(?P<instructor_id>.*)/$', 'instructor_detail'),
(r'^department/(?P<department_id>.*)/$', 'department_detail'),
(r'^course/(?P<course_id>\d+)/search/$', 'course_search'),
+ (r'^course/(?P<course_id>\d+)/edit/$', 'edit_course'),
(ITEM_PREFIX + r'$', 'item_detail'),
(ITEM_PREFIX + r'dl/(?P<filename>.*)$', 'item_download'),
(ITEM_PREFIX + r'meta$', 'item_metadata'),
Modified: servres/trunk/conifer/syrup/views.py
===================================================================
--- servres/trunk/conifer/syrup/views.py 2009-03-08 01:49:15 UTC (rev 144)
+++ servres/trunk/conifer/syrup/views.py 2009-03-08 01:49:33 UTC (rev 145)
@@ -171,20 +171,32 @@
@login_required
def add_new_course(request):
+ return add_or_edit_course(request)
+
+ at login_required
+def edit_course(request, course_id):
+ instance = models.Course.objects.get(pk=course_id)
+ return add_or_edit_course(request, instance=instance)
+
+def add_or_edit_course(request, instance=None):
+ if instance is None:
+ instance = models.Course()
example = models.course_codes.course_code_example
if request.method != 'POST':
- form = NewCourseForm(instance=models.Course())
+ form = NewCourseForm(instance=instance)
return g.render('add_new_course.xhtml', **locals())
else:
- form = NewCourseForm(request.POST, instance=models.Course())
+ form = NewCourseForm(request.POST, instance=instance)
if not form.is_valid():
return g.render('add_new_course.xhtml', **locals())
else:
form.save()
course = form.instance
assert course.id
- mbr = course.member_set.create(user=request.user, role='INSTR')
- mbr.save()
+ user_in_course = models.Member.objects.filter(user=request.user,course=course)
+ if not user_in_course: # for edits, might already be!
+ mbr = course.member_set.create(user=request.user, role='INSTR')
+ mbr.save()
# fixme, need to ask about PASWD and STUDT settings before redirect.
return HttpResponseRedirect('../') # back to My Courses
Modified: servres/trunk/conifer/templates/add_new_course.xhtml
===================================================================
--- servres/trunk/conifer/templates/add_new_course.xhtml 2009-03-08 01:49:15 UTC (rev 144)
+++ servres/trunk/conifer/templates/add_new_course.xhtml 2009-03-08 01:49:33 UTC (rev 145)
@@ -1,5 +1,8 @@
<?python
-title = _('Add a new course site')
+if instance.id:
+ title = _('Edit course details')
+else:
+ title = _('Add a new course site')
?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xi="http://www.w3.org/2001/XInclude"
Modified: servres/trunk/conifer/templates/components/course.xhtml
===================================================================
--- servres/trunk/conifer/templates/components/course.xhtml 2009-03-08 01:49:15 UTC (rev 144)
+++ servres/trunk/conifer/templates/components/course.xhtml 2009-03-08 01:49:33 UTC (rev 145)
@@ -16,11 +16,12 @@
</form>
</div>
- <div py:def="course_banner(course)"
- id="coursebanner">
- <div class="deptident">${course.department}</div>
- ${course_search(course)}
- <h1><a href="${course.course_url()}">${course.code}: ${course.title}</a></h1>
+ <div py:def="course_banner(course)" py:strip="True">
+ <div id="coursebanner">
+ <div class="deptident">${course.department}</div>
+ ${course_search(course)}
+ <h1><a href="${course.course_url()}">${course.code}: ${course.title}</a></h1>
+ </div>
</div>
<!-- !show_tree: display a tree of items in a hierarchical style. -->
Modified: servres/trunk/conifer/templates/course_detail.xhtml
===================================================================
--- servres/trunk/conifer/templates/course_detail.xhtml 2009-03-08 01:49:15 UTC (rev 144)
+++ servres/trunk/conifer/templates/course_detail.xhtml 2009-03-08 01:49:33 UTC (rev 145)
@@ -14,6 +14,9 @@
</head>
<body>
${course_banner(course)}
+ <div py:if="instructs(request.user, course)" id="edit_course_link">
+ <a href="${course.course_url()}edit/">Edit course details</a>
+ </div>
<p py:if="not item_tree">
There are no items associated with this course yet.
</p>
More information about the open-ils-commits
mailing list