SF.net SVN: morphix: [2589] trunk/morphixlivekiosk/scripts/mbuild

[email protected] Thu, 08 Nov 2007 14:43:24 -0800
Newsgroups gmane.linux.morphix.cvs
Message-ID <[email protected]>
Revision: 2589
          http://morphix.svn.sourceforge.net/morphix/?rev=2589&view=rev
Author:   bmsleight
Date:     2007-11-08 14:43:23 -0800 (Thu, 08 Nov 2007)

Log Message:
-----------
I really really _really_ like django

Modified Paths:
--------------
    trunk/morphixlivekiosk/scripts/mbuild/settings.py
    trunk/morphixlivekiosk/scripts/mbuild/templates/emailnotify.html
    trunk/morphixlivekiosk/scripts/mbuild/templates/template.html
    trunk/morphixlivekiosk/scripts/mbuild/urls.py
    trunk/morphixlivekiosk/scripts/mbuild/web/models.py
    trunk/morphixlivekiosk/scripts/mbuild/web/views.py

Added Paths:
-----------
    trunk/morphixlivekiosk/scripts/mbuild/templates/view-queue.html

Modified: trunk/morphixlivekiosk/scripts/mbuild/settings.py
===================================================================
--- trunk/morphixlivekiosk/scripts/mbuild/settings.py	2007-11-07 23:26:27 UTC (rev 2588)
+++ trunk/morphixlivekiosk/scripts/mbuild/settings.py	2007-11-08 22:43:23 UTC (rev 2589)
@@ -81,4 +81,5 @@
     'django.contrib.sessions',
     'django.contrib.sites',
     'mbuild.web',
+    'django.contrib.admin',
 )

Modified: trunk/morphixlivekiosk/scripts/mbuild/templates/emailnotify.html
===================================================================
--- trunk/morphixlivekiosk/scripts/mbuild/templates/emailnotify.html	2007-11-07 23:26:27 UTC (rev 2588)
+++ trunk/morphixlivekiosk/scripts/mbuild/templates/emailnotify.html	2007-11-08 22:43:23 UTC (rev 2589)
@@ -1,3 +1,5 @@
 <h1>Custom Built Kiosk LiveCD</h1>
 
-<p>Will email  {{ emailnotify }} when the elves have built the kiosk.<p>
\ No newline at end of file
+<p>Will email  {{ emailnotify }} when the elves have built the kiosk.<p>
+
+<p>In the meatime - have a look at the <a href=/view-queue/>queue of built and yet to be build kiosks</a><p>
\ No newline at end of file

Modified: trunk/morphixlivekiosk/scripts/mbuild/templates/template.html
===================================================================
--- trunk/morphixlivekiosk/scripts/mbuild/templates/template.html	2007-11-07 23:26:27 UTC (rev 2588)
+++ trunk/morphixlivekiosk/scripts/mbuild/templates/template.html	2007-11-08 22:43:23 UTC (rev 2589)
@@ -1,5 +1,5 @@
 <h1>Custom Built Kiosk LiveCD</h1>
-<p>Template  {{ template }} is added to the queue to be built<p>
+<p>Template  {{ template_name }} is added to the queue to be built<p>
  
 <p>We can email you when the Kiosk has been built.<p>
 <form enctype="multipart/form-data" method="post" action=".">

Added: trunk/morphixlivekiosk/scripts/mbuild/templates/view-queue.html
===================================================================
--- trunk/morphixlivekiosk/scripts/mbuild/templates/view-queue.html	                        (rev 0)
+++ trunk/morphixlivekiosk/scripts/mbuild/templates/view-queue.html	2007-11-08 22:43:23 UTC (rev 2589)
@@ -0,0 +1,11 @@
+<h1>Custom Built Kiosk LiveCD</h1>
+
+{% if queue_list %}
+    <ul>
+    {% for queue in queue_list %}
+        <li>{{ queue.template }} <a href=http://{{ queue.homepage }}>{{ queue.brand }}</a> - Has been built ? {{ queue.built }} </li>
+    {% endfor %}
+    </ul>
+{% else %}
+    <p>No template in current queue.</p>
+{% endif %}
\ No newline at end of file

Modified: trunk/morphixlivekiosk/scripts/mbuild/urls.py
===================================================================
--- trunk/morphixlivekiosk/scripts/mbuild/urls.py	2007-11-07 23:26:27 UTC (rev 2588)
+++ trunk/morphixlivekiosk/scripts/mbuild/urls.py	2007-11-08 22:43:23 UTC (rev 2589)
@@ -3,8 +3,10 @@
 urlpatterns = patterns('',
       (r'^$', 'mbuild.web.views.index'),
       (r'^template/(?P<template>[^/]+)/', 'mbuild.web.views.template'),
+      (r'^view-queue/', 'mbuild.web.views.viewqueue'),
+      (r'^delete-queue/', 'mbuild.web.views.delall'),
 
     # Uncomment this for admin:
-#     (r'^admin/', include('django.contrib.admin.urls')),
+     (r'^admin/', include('django.contrib.admin.urls')),
 
 )

Modified: trunk/morphixlivekiosk/scripts/mbuild/web/models.py
===================================================================
--- trunk/morphixlivekiosk/scripts/mbuild/web/models.py	2007-11-07 23:26:27 UTC (rev 2588)
+++ trunk/morphixlivekiosk/scripts/mbuild/web/models.py	2007-11-08 22:43:23 UTC (rev 2589)
@@ -4,7 +4,8 @@
 
 class Queue(models.Model):
 	template = models.CharField(maxlength="20", primary_key=True)
-	brand = models.CharField(maxlength="20")
+	brand = models.CharField(maxlength="150")
 	built = models.BooleanField(default=False, 
 					help_text="Has Kiosk been built")
 	notifybyemail = models.EmailField(null=True)
+	homepage = models.CharField(maxlength="150")
\ No newline at end of file

Modified: trunk/morphixlivekiosk/scripts/mbuild/web/views.py
===================================================================
--- trunk/morphixlivekiosk/scripts/mbuild/web/views.py	2007-11-07 23:26:27 UTC (rev 2588)
+++ trunk/morphixlivekiosk/scripts/mbuild/web/views.py	2007-11-08 22:43:23 UTC (rev 2589)
@@ -44,7 +44,12 @@
       
       tree = ET.ElementTree(root)
       tree.write("/var/www/templates/%s.xml" % uniq)
-      return HttpResponseRedirect("/template/%s.xml/" % uniq ) 
+      
+      #Save details to dBase
+      template_name = "%s.xml" % uniq
+      template = Queue(template=template_name, brand=cd['brand_name'], homepage=cd['homepage'])
+      template.save()
+      return HttpResponseRedirect("/template/%s/" % template_name ) 
   else:
     form = BuildForm()
     
@@ -57,6 +62,12 @@
       emailnotify = forms.EmailField("Email to recieve notifications?")
   if request.POST:
     emailnotify = request.POST["emailnotify"]
+    try:
+	newtemplate = Queue.objects.get(pk=template)
+	newtemplate.notifybyemail = emailnotify
+	newtemplate.save()
+    except Queue.DoesNotExist:
+	    return HttpResponse("Template does not exist")
     return render_to_response("emailnotify.html",{"emailnotify":emailnotify})
   else:
     form = BuildForm()    
@@ -64,3 +75,11 @@
   return render_to_response('index.html', context,
                             context_instance=RequestContext(request))
 
+def viewqueue(request):
+    queue_list = Queue.objects.all().order_by('template')
+    return render_to_response('view-queue.html', {'queue_list': queue_list})
+
+def delall(request):
+    # Will disable when running live
+    Queue.objects.all().delete()
+    return HttpResponse("The Elves have deleted the whole queue.")


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/