Commits

Michele Orrù committed 704d92f Merge

merge

Comments (0)

Files changed (7)

seedswap/media/style.css

 
 #menu .first {
 }
-/* account dashboard */
 
-#account_dashboard {
-	float: right;
-	padding: 10px 10px 0px 0px;
+/* Search */
+
+#login {
+    float: right;
+    padding: 10px 10px 0px 0px;
 }
 
+#login form {
+    float: right;
+    margin: 0;
+    padding: 4px 0px 0 0;
+}
 
-#account_dashboard-text {
-	width: 213px;
-	height: 28px;
-	padding: 6px 0 0 7px;
-	border: none;
-	background: url(images/img02.jpg) no-repeat left top;
-	color: #000000;
+#login fieldset {
+    margin: 0;
+    padding: 0;
+    border: none;
 }
 
 /* Page */
 
 #footer a {
 }
+
+
+.smallmap {
+    width: 512px;
+    height: 256px;
+    border: 1px solid #ccc;
+}

seedswap/seed/forms.py

-# -*- coding: utf-8 -*-
+ # -*- coding: utf-8 -*-
 
 import datetime
 

seedswap/seed/templates/base.html

 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
-<title>Assiduous   by Free CSS Templates</title>
+<title>Seed Swap App</title>
 <meta name="keywords" content="" />
 <meta name="description" content="" />
 {% block page_headers %}
+
+<script type="text/javascript">
+    function init() {}
+</script>
+
 {% endblock %}
 <link href="/static/style.css" rel="stylesheet" type="text/css" media="screen" />
 </head>
-<body>
+<body onload="init()">
 <div id="header-wrapper">
 	<div id="header">
 		<div id="menu">
 			</ul>
 		</div>
 		<!-- end #menu -->
-        {% if user.is_authenticated %}
-        <!--account dashboard -->
-		<div id="account_dashboard">
-            Portanna
-		</div>
-        {% else %}
+        {% if not user.is_authenticated %}
             <form method="POST" action="/user/login">
             Username: <input type="text" name="username" size="15" />
             Password: <input type="password" name="password" size="15" />
                 <p><input type="submit" value="Login" /></p>
             </div>
             </form>
+        </div>
         {% endif %}
 		<!-- end #account_dashboard -->
 	</div>
 		</div>
 		<!-- end #content -->
         <div id="sidebar">
-            {% block sedebar %}
+            {% block sidebar %}
             {% endblock %}
 		</div>
 		<!-- end #sidebar -->

seedswap/seed/templates/index.html

 {% block sidebar %}
 {% if logged %}
 <ul>
-    <li><a href="#">A few links</a></li>
+    <li>
+        Seeds
+        <li>
+            <a href="/seed/search">Search</a>
+        </li>
+    </li>
+    <li>
+        User
+        <li>
+            <a href="/">Dashboard</a>
+        </li>
+    </li>
 </ul>
 {% else %}
 <ul>
     <li>
-        <h2><a href="/user/signup">Sign up</a></h2>
-    </li>
-    <li>
-        <ul>
-            <li><a href="#">A few links</a></li>
-        </ul>
+        Start swapping!
+        <li>
+            <h2><a href="/user/signup">Sign up</a></h2>
+        </li>
     </li>
 </ul>
 {% endif %}

seedswap/seed/templates/search.html

 {% extends "base.html" %}
 {% block page_headers %}
 
-<script src="js/OL/OpenLayers.js"></script>
+<script src="/static/js/OL/OpenLayers.js"></script>
 <script type="text/javascript">
     var map, layer;
     function init(){
 {% block page_title %}
 About
 {% endblock %}
+
+
 {% block content %}
-<form action="/seed/search.html" method="post">{% csrf_token %}
+<div class="entry" >
+ <form action="/seed/search" method="post">{% csrf_token %}
 {{ form.as_p }}
-<input type="submit" value="Submit" />
+<!-- <input type="submit" value="Submit" /> -->
 </form>
 
-<div class="map">
+<div id="map" class="smallmap" />
 </div>
-
 {% endblock %}
 

seedswap/seed/views.py

 # Create your views here.
+
+import json
+
 from django.shortcuts import render_to_response, redirect
 from django.http import HttpResponse
 
 from django.template import RequestContext
 
 from seed.models import UserProfile, Species, Varieties, Seed
-from seed.forms import SearchForm, InsertSeedForm, InsertSpeciesForm, InsertVarietiesForm
+from seed.forms import SearchForm, InsertSeedForm, InsertSpeciesForm, InsertVarietiesForm, InsertUserForm
 
 def add_seeds(request):
     """
     TODO: add login requirement
     """
     if request.method == 'POST':
-        myForm = InsertUserForm(request.POST)
+        myForm = InsertSeedForm(request.POST)
         if myForm.is_valid():
             seeditem = myForm.save(commit=False)
             seeditem.user = request.user
             myForm.save()
             return HttpResponse('Record correctly inserted.')
     else:
+        myForm = InsertSpeciesForm()
+    return render_to_response("insertSeed.html", {'logged' : request.user.is_authenticated(), "form": myForm})
+
+def add_user(request):
+    """ Minimalist form to insert specie. """
+    if request.method == 'POST':
+        myForm = InsertUserForm(request.POST)
+        if myForm.is_valid():
+            myForm.save()
+            return HttpResponse('Record correctly inserted.')
+    else:
         myForm = InsertUserForm()
     return render_to_response("insertSeed.html",
                               dict(form = myForm),
                               dict(form = myForm),
                               context_instance=RequestContext(request))
 
-def register(request):
-    if request.method == 'POST':
-            return HttpResponse('User added!')
-
-    return render_to_response('register.html', {'logged' : request.user.is_authenticated()})
-
 def index(request):
     return render_to_response('index.html',
                               context_instance=RequestContext(request))
                               context_instance=RequestContext(request))
 
 def search(request):
-    all_seeds = Seed.objects.all()
+
     if request.method == 'POST':
         form = forms.SearchForm(request.POST)
         if form.is_valid():
-            data = {}
-            return data
+            all_seeds = Seed.objects.all()
+            print all_seeds
+            rdata = {}
+            return HttpResponse(json.dumps(rdata), mimetype="application/json")
     else:
         form = forms.SearchForm()
         return render_to_response('search.html',
         url(r'^seed/search$', 'search'),
         url(r'^contacts$', 'contacts'),
         url(r'^about$', 'about'),
-        url(r'^user/signup$', 'register'),
+        url(r'^user/signup$', 'add_user'),
         url(r'^$', 'index'),
         url(r'^seed/(?P<seed_id>\d{10})$', 'view'),
 )