Commits

Anonymous committed 2803e37

Changes to work with Django 1.2

  • Participants
  • Parent commits 3a7aabc

Comments (0)

Files changed (9)

File repos/views.py

 from freehg.repos.models import Repo, FreeHGConf
 from django.contrib.auth.models import User
 from django.shortcuts import get_object_or_404, render_to_response
-from django.template import Context, RequestContext
+from django.views.decorators.csrf import csrf_protect
+from django.template import RequestContext
 from django.contrib.auth import login, authenticate
 from django.http import HttpResponseRedirect
 from django.contrib.auth.decorators import login_required
 from django.db.models import ObjectDoesNotExist
 from django.shortcuts import redirect
 
+
 from freehg.repos.forms import (NewRepoForm, NewAccountForm, LoginForm,
         EditRepoForm)
 
 
 rfc822date = lambda x: util.datestr(x, "%a, %d %b %Y %H:%M:%S")
 
-
+@csrf_protect
 def frontpage(request):
     if request.POST.get('reponame', False):
         repo_form = NewRepoForm(request.POST)
 # Django settings for freehg project.
+import os
 
 DEBUG = True
 TEMPLATE_DEBUG = DEBUG
 
 ADMINS = (
-    # ('', ''),
+    # ('Your Name', 'your_email@domain.com'),
 )
 
 MANAGERS = ADMINS
 
-DATABASE_ENGINE = 'mysql'           # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
-DATABASE_NAME = 'freehg'             # Or path to database file if using sqlite3.
-DATABASE_USER = 'freehg'             # Not used with sqlite3.
-DATABASE_PASSWORD = 'fr33hg'         # Not used with sqlite3.
-DATABASE_HOST = ''             # Set to empty string for localhost. Not used with sqlite3.
-DATABASE_PORT = ''             # Set to empty string for default. Not used with sqlite3.
+DATABASES = {
+    'default': {
+        'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
+        'NAME': 'hgbox',                      # Or path to database file if using sqlite3.
+        'USER': 'hgbox',                      # Not used with sqlite3.
+        'PASSWORD': 'hgbox',                  # Not used with sqlite3.
+        'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
+        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
+    }
+}
 
 # Local time zone for this installation. Choices can be found here:
 # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
 # although not all choices may be available on all operating systems.
+# On Unix systems, a value of None will cause Django to use the same
+# timezone as the operating system.
 # If running in a Windows environment this must be set to the same as your
 # system time zone.
 TIME_ZONE = 'America/Manaus'
 # to load the internationalization machinery.
 USE_I18N = True
 
+# If you set this to False, Django will not format dates, numbers and
+# calendars according to the current locale
+USE_L10N = True
+
 # Absolute path to the directory that holds media.
 # Example: "/home/media/media.lawrence.com/"
 MEDIA_ROOT = ''
 # Examples: "http://foo.com/media/", "/media/".
 ADMIN_MEDIA_PREFIX = '/adminmedia/'
 
+# Make this unique, and don't share it with anybody.
+SECRET_KEY = 'rk%r3dwfc&=%w&u=fqz^##hm8fpxoue!p=1ye0-#%b&uk*cv+2'
+
 # List of callables that know how to import templates from various sources.
 TEMPLATE_LOADERS = (
-    'django.template.loaders.filesystem.load_template_source',
-    'django.template.loaders.app_directories.load_template_source',
-#     'django.template.loaders.eggs.load_template_source',
+    'django.template.loaders.filesystem.Loader',
+    'django.template.loaders.app_directories.Loader',
+#     'django.template.loaders.eggs.Loader',
 )
 
-import os
-
 #FREEHG_LDAP_SERVER_ADDRESS = "ldap://fpfserver10"
 #FREEHG_LDAP_BASE = "DC=dom,DC=fpf,DC=br"
 #FREEHG_LDAP_DOMAIN = "dom.fpf.br"
 MIDDLEWARE_CLASSES = (
     'django.middleware.common.CommonMiddleware',
     'django.contrib.sessions.middleware.SessionMiddleware',
+    'django.middleware.csrf.CsrfViewMiddleware',
     'django.contrib.auth.middleware.AuthenticationMiddleware',
-    'django.middleware.doc.XViewMiddleware',
+    'django.contrib.messages.middleware.MessageMiddleware',
 )
 
 ROOT_URLCONF = 'freehg.urls'
     os.path.join(os.path.dirname(__file__), 'templates'),
 )
 
-TEMPLATE_CONTEXT_PROCESSORS = (
-    'django.core.context_processors.auth',
-    'freehg.context_processors.softwaresVersions',
-)
-
-
 INSTALLED_APPS = (
     'django.contrib.auth',
     'django.contrib.contenttypes',
     'django.contrib.sessions',
     'django.contrib.sites',
+    'django.contrib.messages',
+    # Uncomment the next line to enable the admin:
     'django.contrib.admin',
     'freehg.repos',
-)
-
+)

File templates/base.html

 		</div><!-- #content -->
 		<div id="clear"></div>
 		<div id="footer">
-			<div>freeHg copyright 2009 by <strong>freeHg Team</strong> | Django <strong>{{django_version}}</strong> / Hg <strong>{{hg_version}}</strong></div>
+			<div>freeHg copyright 2010 by <strong>freeHg Team</strong> | Django <strong>{{django_version}}</strong> / Hg <strong>{{hg_version}}</strong></div>
 		</div><!-- #footer -->
 	</div><!-- #main -->
 </body>

File templates/frontpage.html

 				<div id="create-repo" class="dialog">
 					<p class="title"><strong>Create a repository</strong></p>
 					<ul>
-						<form action='.' method='post'>
+						<form action='.' method='post'>{% csrf_token %}
 						{% for field in repo_form %}
 						<li class="label">{{field.label_tag}}:</li>
 						<li class="field">{{field}}</li>
 				</div><!-- #repos -->
 				{% else %}
 				<div id="login-box" class="dialog">
-					<form action='./' method='post'>
+					<form action='./' method='post'>{% csrf_token %}
 						<p class="title"><strong>Login</strong></p>
 						<ul>
 							{% for field in login_form %}

File templates/profile.html

 	<div id="profile-edit" class="dialog">
 		<p class="title"><strong>Edit</strong></p>
 		<ul>
-			<form method="post" action=".">
+			<form method="post" action=".">{% csrf_token %}
 			{% for field in form %}
 			<li class="body">{{field.label_tag}}</li>
 			<li class="body">{{field}}</li>

File templates/registration/login.html

 <p class="error">{{ error_message }}</p>
 {% endif %}
 
-<form action="{{ app_path }}" method="post" id="login-form">
+<form action="{{ app_path }}" method="post" id="login-form">{% csrf_token %}
 <div class="span-7 last">
     <fieldset>
         <legend>Login:</legend>

File templates/registration/password_change_form.html

 {% block content %}
 <div id="password-change" class="dialog">
 	<p class="title"><strong>Password change</strong></p>
-	<form action="" method="post">
+	<form action="" method="post">{% csrf_token %}	
 	<ul>
 		<li class="body">Please enter your old password, for security's sake, and then enter your new password twice so we can verify you typed it in correctly.</li>
 		<li>&nbsp;</li>

File templates/repos/delete.html

 {% block content %}
 <div id="repo-delete" class="dialog">
   <p class="title"><strong>Delete</strong> ~ {{repo.get_long_name}}</p>
-	<form method="POST" action='.'>
+	<form method="POST" action='.'>{% csrf_token %}
 	  <ul>
 	  	<li class="body">Are you sure you want to permanently delete {{repo.get_long_name}}?</li>
 	  	<li class="body">&nbsp;</li>

File templates/repos/edit.html

 {% block content %}
 <div id="repo-edit" class="dialog">
 	<p class="title"><strong>Editing</strong> ~ {{repo.get_long_name}}</p>
-	<form method="POST" action=".">
+	<form method="POST" action=".">{% csrf_token %}
 		<ul>
 		  {% for field in form %}
 			{% if field.errors %}<li class="body">{{field.errors}}</li>{% endif %}