changeset 82:31335dd18f61

Merge branch 'master' of Beuc@git.sv.gnu.org:/srv/git/savane-cleanup/framework
author Sylvain Beucler <beuc@beuc.net>
date Sun, 26 Jul 2009 17:31:18 +0200
parents 352cce412bae (current diff) 825d3b34ca1d (diff)
children 45933e4a5aec
files
diffstat 12 files changed, 238 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/media/css/Savannah.css
+++ b/media/css/Savannah.css
@@ -73,6 +73,7 @@
    border-style: solid;
    border-width: 0 1px 1px 0;
    margin: 0px;
+   margin-top: 10px;
 }
 
 
@@ -153,12 +154,22 @@
 
 .menu_left {
    margin-top: 0px;
-   width: 18%;
+   width: 15%;
    height: 300px;
    background-color: #ffe4b7;
    float: left;
    margin: 4px;
    border: thin dotted #E0C080;
+   padding: 10px;
+}
+
+.menu_left ul {
+   margin: 0px;
+   margin-bottom: 10px;
+}
+.menu_left li {
+   list-style-type: none;
+   margin-left: -30px;
 }
 
 /* End Menu */
new file mode 100644
--- /dev/null
+++ b/migrate_old_savane.sql
@@ -0,0 +1,3 @@
+insert into auth_user (id, username, first_name, email, password, last_login, date_joined) select user_id, user_name, trim(convert(realname using latin1)), email, user_pw, now(), from_unixtime(add_date) from savane_old.user;
+
+insert into user (user_ptr_id, status,spamscore, confirm_hash, authorized_keys, authorized_keys_count, people_view_skills, people_resume, timezone, theme, email_hide, gpg_key, gpg_key_count) select user_id, status,spamscore, confirm_hash, authorized_keys, authorized_keys_count, people_view_skills, convert(people_resume using latin1), timezone, theme, email_hide, gpg_key, gpg_key_count from  savane_old.user;
new file mode 100644
--- /dev/null
+++ b/savane/main/urls.py
@@ -0,0 +1,12 @@
+from django.conf.urls.defaults import *
+from main import views
+
+
+urlpatterns = patterns ('',
+                        url('^$',
+                            views.index,
+                            ),
+                        url('^contact$',
+                            views.contact,
+                            ),
+                        )
--- a/savane/main/views.py
+++ b/savane/main/views.py
@@ -3,5 +3,11 @@
 from django.http import HttpResponse
 
 def index(request):
-    return render_to_response( 'index.html', RequestContext( request, {'has_left_menu': False},
-                                                               ) )
+    return render_to_response( 'index.html',
+                               RequestContext( request, {'has_left_menu': False},
+                                               ) )
+
+def contact( request ):
+    return render_to_response( 'contact.html',
+                               RequestContext( request,
+                                               ))
new file mode 100644
--- /dev/null
+++ b/savane/savane_user/backend.py
@@ -0,0 +1,20 @@
+from savane_user.models import User
+from django.contrib.auth.backends import ModelBackend
+
+class SavaneAuthBackend( ModelBackend ):
+    """
+    Authenticate against the savane_user model
+    """
+    def authenticate( self, username, password ):
+        try:
+            user = User.objects.get(username=username)
+            if user.check_password(password):
+                return user
+        except User.DoesNotExist:
+            return None
+
+    def get_user(self, user_id):
+        try:
+            return User.objects.get(pk=user_id)
+        except User.DoesNotExist:
+            return None
--- a/savane/savane_user/models.py
+++ b/savane/savane_user/models.py
@@ -1,10 +1,8 @@
 from django.db import models
-#from django.db.models import Manager
 from django.contrib.auth.models import User, UserManager
-#from django.contrib.auth.models import User
 
 class User(User):
-    realname = models.CharField(max_length=96)
+#    realname = models.CharField(max_length=96)
     status = models.CharField(max_length=48)
     spamscore = models.IntegerField(null=True, blank=True)
     confirm_hash = models.CharField(max_length=96, blank=True, null=True)
--- a/savane/savane_user/views.py
+++ b/savane/savane_user/views.py
@@ -1,35 +1,43 @@
 from django.template import RequestContext
 from django.shortcuts import render_to_response
-from django.http import HttpResponse, HttpResponseRedirect
+from django.http import HttpResponseRedirect
 from django.contrib.auth import authenticate, login, logout
+from django.contrib.auth.decorators import login_required
 from django import forms
+from savane_user.models import User
 
 def index( request ):
     return render_to_response( 'savane_user/index.html',
                                RequestContext( request,
                                                ) )
 def sv_login( request ):
-    username = request.POST['username']
-    password = request.POST['password']
+
+    if request.method == 'POST':
+        username = request.POST['username']
+        password = request.POST['password']
 
-    user = authenticate( username=username, password=password )
+        if username != '' and password != '':
+            user = authenticate( username=username, password=password )
+        else:
+            user = None
 
-    if user is not None:
-        login( request, user )
-    else:
-        login_error = u"User or password didn't match"
-        return render_to_response( 'error.html',
-                                   {'error' : login_error
-                                    } )
+        if user is not None:
+            login( request, user )
+        else:
+            login_error = u"User or password didn't match"
+            return render_to_response( 'error.html',
+                                       {'error' : login_error
+                                        } )
 
-    return HttpResponseRedirect ( '/' )
+    return HttpResponseRedirect ( '/user/' )
 
+@login_required()
 def sv_logout( request ):
     logout( request )
 
     return HttpResponseRedirect( '/' )
 
-
+@login_required()
 def sv_conf( request ):
 
     error_msg = ''
@@ -83,14 +91,69 @@
                                                  }
                                                ) )
 
+@login_required()
 def sv_resume_skill( request ):
     return render_to_response( 'savane_user/resume_skill.html',
                                RequestContext( request,
                                                ) )
+@login_required()
+def sv_ssh_gpg( request ):
 
-def sv_ssh_gpg( request ):
+    error_msg = None
+    success_msg = None
+
+    form_ssh = SSHForm()
+    form_gpg = GPGForm()
+
+    if request.method == 'POST':
+        form = None
+        action = request.POST['action']
+        if action == 'update_ssh':
+            form_ssh = SSHForm( request.POST )
+            form = form_ssh
+        elif action == 'update_gpg':
+            form_gpg = GPGForm( request.POST )
+
+        if form is not None and form.is_valid():
+            if action == 'update_ssh':
+                keys = list()
+                for i in range( 1, 6 ):
+                    key_str = 'key_'+str(i)
+                    key = request.POST[ key_str ]
+                    if key != '':
+                        keys.append( key )
+                keys_str = str('###').join( keys )
+
+                request.user.authorized_keys = keys_str
+                request.user.save()
+                success_msg = 'Authorized keys stored.'
+            elif action == 'update_gpg':
+                pass
+    else:
+        if request.user.authorized_keys != '':
+            keys_data = dict({'action':'update_ssh'})
+            keys = request.user.authorized_keys.split('###')
+            i = 1
+            for key in keys:
+                key_str = 'key_'+str(i)
+                keys_data[ key_str ] = key
+                i += 1
+                form_ssh = SSHForm( keys_data )
+        else:
+            form_ssh = SSHForm()
+
+        if request.user.gpg_key != '':
+            gpg_data = dict({'action':'update_gpg', 'gpg_key':request.user.gpg_key})
+            form_gpg = GPGForm( gpg_data )
+        else:
+            form_gpg = GPGForm()
+
+
     return render_to_response( 'savane_user/ssh_gpg.html',
                                RequestContext( request,
+                                               { 'form_gpg' : form_gpg,
+                                                 'form_ssh' : form_ssh,
+                                                 }
                                                ) )
 
 class MailForm( forms.Form ):
@@ -112,3 +175,16 @@
     name = forms.CharField( required = True )
     last_name = forms.CharField( required = False )
     action = forms.CharField( widget=forms.HiddenInput, required=True, initial='update_identity' )
+
+class GPGForm( forms.Form ):
+    gpg_key = forms.CharField( widget=forms.Textarea( attrs={'cols':'70','rows':'15'} ), required=False )
+    action = forms.CharField( widget=forms.HiddenInput, required=True, initial='update_gpg' )
+
+class SSHForm( forms.Form ):
+    widget = forms.TextInput( attrs={'size':'60'} )
+    key_1 = forms.CharField( widget=widget, required=False )
+    key_2 = forms.CharField( widget=widget, required=False )
+    key_3 = forms.CharField( widget=widget, required=False )
+    key_4 = forms.CharField( widget=widget, required=False )
+    key_5 = forms.CharField( widget=widget, required=False )
+    action = forms.CharField( widget=forms.HiddenInput, required=True, initial='update_ssh' )
--- a/savane/settings.py
+++ b/savane/settings.py
@@ -84,6 +84,12 @@
 )
 STATIC_ROOT = '../media/'
 
+AUTHENTICATION_BACKENDS = (
+    'savane.savane_user.backend.SavaneAuthBackend',
+)
+
+LOGIN_URL = '/user/'
+
 INSTALLED_APPS = (
     'django.contrib.auth',
     'django.contrib.contenttypes',
--- a/savane/urls.py
+++ b/savane/urls.py
@@ -6,8 +6,8 @@
 # admin.autodiscover()
 
 urlpatterns = patterns('',
-                       (r'^$', "main.views.index"),
-
+#                       (r'^$', "main.views.index"),
+                       (r'', include('main.urls')),
                        (r'^user/', include('savane_user.urls')),
 
                        # Uncomment the next line to enable the admin:
--- a/template/base.html
+++ b/template/base.html
@@ -6,14 +6,12 @@
     <meta name="Generator" content="Savane 3.1-cleanup, see http://savannah.nongnu.org/projects/savane-cleanup" />
     <meta http-equiv="Content-Script-Type" content="text/javascript" />
     <link rel="stylesheet" type="text/css" href="{{MEDIA_URL}}/css/Savannah.css" />
-    <link rel="icon" type="image/png" href="static/images/icon.png" />
+    <link rel="icon" type="image/png" href="{{MEDIA_URL}}/images/icon.png" />
     <meta name="Author" content="Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved" />
     <meta name="Keywords" content="Savannah,GNU, FSF, Free Software Foundation, GNU/Linux, Linux, Emacs, GCC, Unix, Free Software, Operating System, GNU Kernel, HURD, gnus, SourceForge" />
     <meta name="Description" content="Savannah is a central point for development, distribution and maintainance of Free Software. It allows contributors to easily join existing Free Software projects." />
 
   </head>
-
-  {{request.GET.test}}
   <body>
     <div class="main_menu">
       <a href="/"><img src="{{MEDIA_URL}}/images/floating.png" alt="Back to Savannah Homepage" border="0" width="118" height="100" /></a>
@@ -46,7 +44,7 @@
     </div>
     {% else %}
     <div class="menu_login">
-      <form action="/user/login" method="post">
+      <form action="{% url savane_user.views.sv_login %}" method="post">
         <input type="hidden" name="uri" value="/" />
         <dl>
           <dt>Login Name:</dt>
@@ -62,6 +60,30 @@
       <div class="body">
         {% ifequal has_left_menu None %}
         <div class="menu_left">
+          <strong>Site Help</strong>
+          <ul>
+            <li><a>User Docs: Cookbook</a></li>
+            <li><a>User Docs: In Depth Guide</a></li>
+            <li><a>Get Support</a></li>
+            <li><a href="{% url main.views.contact %}">Contact Us</a></li>
+            <li><a href="http://savannah.gnu.org/maintenance/CvsAnonymous">CVS Instructions</a></li>
+            <li><a href="http://savannah.gnu.org/maintenance/FaQ">FAQ</a></li>
+          </ul>
+          <strong>GNU Project</strong>
+          <ul>
+            <li><a href="http://www.gnu.org/help/help.html" target="_blank">Help GNU</a></li>
+            <li><a href="http://www.gnu.org/directory/GNU" target="_blank">All GNU Packages</a></li>
+            <li><a href="http://www.gnu.org/software/devel.html" target="_blank">Dev Resources</a></li>
+            <li><a href="http://www.gnu.org/licenses/license-list.html" target="_blank">License List</a></li>
+            <li><a href="http://www.gnu.org/prep/ftp.htm" target="_blank">GNU Mirrors</a></li>
+          </ul>
+          <strong>Free Software Foundation</strong>
+          <ul>
+            <li><a href="http://www.fsf.org/events/" target="_blank">Coming Events</a></li>
+            <li><a href="http://gplv3.fsf.org/" target="_blank">GNU GPL v3</a></li>
+            <li><a href="http://www.fsf.org/directory/" target="_blank">Free Software Directory</a></li>
+            <li><a href="http://savannah.gnu.org/maintenance/SavannahCryptographicRestrictions" target="_blank">Cryptographic software legal notice</a></li>
+          </ul>
         </div>
         {% endifequal %}
         <div class="content">
new file mode 100644
--- /dev/null
+++ b/template/contact.html
@@ -0,0 +1,44 @@
+{% extends "base.html" %}
+
+{% block content %}
+
+<h2>E-mail contact</h2>
+
+<p>Note: If you need to get in touch with the developers of a
+particular project hosted here, please <em>check the project's page</em>
+(e.g. <code>/projects/myprojecname</code>) to find out the appropriate
+way to contact them.</p>
+
+<p>For general help with using the service, you can subscribe to the
+<strong>users mailing lists</strong> at <a
+href="http://lists.gnu.org/mailman/listinfo/savannah-users">http://lists.gnu.org/mailman/listinfo/savannah-users</a>
+and send mail to <a
+href="mailto:savannah-users@gnu.org">savannah-users@gnu.org</a> <span style="font-size: smaller">(mails
+from non-members are accepted but moderated on a daily basis)</span>.</p>
+
+<p>If you are the developer of one of the projects hosted here and you
+want to get in touch with the maintainers of this server (Savannah)
+you can then contact the <strong>Savannah Hackers</strong> by submitting a
+
+
+<a href="/support/?func=addsupport&amp;group=administration">[support request]</a>
+or sending mail to <a
+href="mailto:savannah-help-public@gnu.org">savannah-help-public@gnu.org</a>
+(after checking the archives at <a
+href="http://lists.gnu.org/archive/html/savannah-hackers/">http://lists.gnu.org/archive/html/savannah-hackers/</a>)
+- when you want to contact us about security or confidential issues,
+you may also use the savannah-help-private@gnu.org list.</p>
+
+<p>If you have found a bug in the Savane software (the software used
+to run this server), or you would like to request a new feature, you
+should use the Bugs system in <a
+href="http://gna.org/projects/savane">Project Savane</a>.</p>
+
+{% endblock %}
+{% comment %}
+Local Variables: **
+mode: django-html **
+tab-width: 4 **
+indent-tabs-mode: nil **
+End: **
+{% endcomment %}
--- a/template/savane_user/ssh_gpg.html
+++ b/template/savane_user/ssh_gpg.html
@@ -7,6 +7,20 @@
   <li><a href="{% url savane_user.views.sv_ssh_gpg %}">SSH/GPG Keys</a></li>
 </ul>
 
+<h3>SSH Keys</h3>
+<form method="post">
+  {{ form_ssh.as_p }}
+  <br /><input type="submit" value="Save" name="Save" />
+</form>
+
+
+
+<h3>GPG Key</h3>
+<form method="post">
+  {{ form_gpg.as_p }}
+  <br /><input type="submit" value="Update" name="Update" />
+</form>
+
 
 {% endblock %}
 {% comment %}