[cig-commits] r14463 - in cs/portal/junk: . northridge-django-v1.0/SeismoWebPortal northridge-django-v1.0/SeismoWebPortal/sql northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal northridge-django-v1.0/SeismoWebPortal/templates/registration
leif at geodynamics.org
leif at geodynamics.org
Wed Mar 25 20:18:09 PDT 2009
Author: leif
Date: 2009-03-25 20:18:07 -0700 (Wed, 25 Mar 2009)
New Revision: 14463
Added:
cs/portal/junk/northridge-django-v1.0/
Modified:
cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/forms.py
cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/management.py
cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/mezzanine.py
cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/models.py
cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/sql/stationnetwork.sql
cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/cluster_queueWaitTime_form.html
cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/cpu_time_request_form.html
cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/event_form.html
cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/event_search.html
cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/event_upload.html
cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/job_form.html
cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/job_progress_form.html
cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/mesh_form_base.html
cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/mineosmodecatalog_form.html
cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/mineosmodel_form.html
cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/mineosmodel_upload.html
cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/mineosparameters_form.html
cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/outputfile_form.html
cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/password_change_form.html
cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/register.html
cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/run_form.html
cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/single_source_event_form.html
cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobemodel_detail.html
cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobemodel_form.html
cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobemodel_link.html
cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobemodel_upload.html
cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobeparameters_form.html
cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/stationlist_form.html
cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/stationlist_upload.html
cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/userinfo_form.html
cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/registration/login.html
cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/registration/pwreset.html
cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/views.py
Log:
Aborted attempt to port the seismo portal from Django v0.96 to Django v1.0.
Copied: cs/portal/junk/northridge-django-v1.0 (from rev 14420, cs/portal/trunk/northridge)
Modified: cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/forms.py
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/forms.py 2009-03-23 15:19:28 UTC (rev 14420)
+++ cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/forms.py 2009-03-26 03:18:07 UTC (rev 14463)
@@ -3,7 +3,8 @@
from django.contrib.auth import authenticate, login
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
-from django.core import validators
+from django.core.exceptions import ValidationError
+from django.forms import widgets
import cmt
import models
@@ -56,7 +57,7 @@
return
-class MeshAddManipulator(models.Specfem3DGlobeMesh.AddManipulator, MeshManipulator):
+class MeshAddManipulator(object): # XXX (models.Specfem3DGlobeMesh.AddManipulator, MeshManipulator):
def __init__(self, nchunks):
models.Specfem3DGlobeMesh.AddManipulator.__init__(self)
MeshManipulator.__init__(self, nchunks)
@@ -66,7 +67,7 @@
return models.Specfem3DGlobeMesh.AddManipulator.save(self, new_data)
-class MeshChangeManipulator(models.Specfem3DGlobeMesh.ChangeManipulator, MeshManipulator):
+class MeshChangeManipulator(object): # XXX (models.Specfem3DGlobeMesh.ChangeManipulator, MeshManipulator):
def __init__(self, nchunks, object_id):
models.Specfem3DGlobeMesh.ChangeManipulator.__init__(self, object_id)
MeshManipulator.__init__(self, nchunks)
@@ -87,7 +88,7 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-class RunManipulator(forms.Manipulator):
+class RunManipulator(object): # XXX (forms.Manipulator):
def __init__(self, user, objId=None):
from django.db.models import BLANK_CHOICE_DASH as blank
@@ -182,7 +183,7 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-class JobProgressManipulator(forms.Manipulator):
+class JobProgressManipulator(object): # XXX (forms.Manipulator):
def __init__(self, object_id, **kwds):
from django.shortcuts import get_object_or_404
@@ -206,7 +207,7 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-class ClusterQueueWaitTimeManipulator(forms.Manipulator):
+class ClusterQueueWaitTimeManipulator(object): # XXX (forms.Manipulator):
def __init__(self, cluster):
self.cluster = cluster
@@ -237,13 +238,13 @@
User.objects.get(username = field_data)
except User.DoesNotExist:
return
- raise validators.ValidationError(usernameTaken)
+ raise ValidationError(usernameTaken)
def passwordsMatch(new_data, all_data):
"Validates that the two password fields match."
if new_data != all_data['password1']:
- raise validators.ValidationError, "Your passwords didn't match."
+ raise ValidationError, "Your passwords didn't match."
return
@@ -253,19 +254,28 @@
)
-def addPubFields(fields):
+def addPubFields(fields): # XXX
fields.extend([
forms.RadioSelectField('pubType', choices=pubTypeChoices),
- forms.TextField('authors', maxlength=100),
- forms.TextField('title', maxlength=100),
- forms.TextField('journal', maxlength=100),
- forms.TextField('biblio', maxlength=100),
+ forms.TextField('authors', max_length=100),
+ forms.TextField('title', max_length=100),
+ forms.TextField('journal', max_length=100),
+ forms.TextField('biblio', max_length=100),
forms.FileUploadField(field_name='paper1'),
forms.FileUploadField(field_name='paper2'),
])
return
+class PubForm(forms.Form):
+ pubType = forms.ChoiceField(choices=pubTypeChoices, required=False)
+ authors = forms.CharField(widget=widgets.Textarea, max_length=100, required=False)
+ title = forms.CharField(widget=widgets.Textarea, max_length=100, required=False)
+ journal = forms.CharField(widget=widgets.Textarea, max_length=100, required=False)
+ biblio = forms.CharField(widget=widgets.Textarea, max_length=100, required=False)
+ paper1 = forms.FileField(required=False)
+ paper2 = forms.FileField(required=False)
+
def pubDefaults():
return {'pubType': 0}
@@ -299,49 +309,43 @@
return
-class RegistrationManipulator(forms.Manipulator):
+class ContactForm(forms.Form):
- def __init__(self):
- from models import ROLE_CHOICES
-
- roleChoices = (('', '---------'),) + ROLE_CHOICES
+ from models import ROLE_CHOICES
+ roleChoices = (('', '---------'),) + ROLE_CHOICES
- self.fields = [
- # User
- forms.TextField('first_name', maxlength=30, is_required=True),
- forms.TextField('last_name', maxlength=30, is_required=True),
- forms.EmailField('email', is_required=True, validator_list=[self.isUniqueEmail]),
- # UserInfo
- forms.SelectField(field_name='role', choices=roleChoices, is_required=True),
- forms.TextField('adviser', maxlength=100),
- forms.TextField('institution', maxlength=100, is_required=True),
- forms.TextField('address1', maxlength=100, is_required=True),
- forms.TextField('address2', maxlength=100, is_required=True),
- forms.TextField('address3', maxlength=100, is_required=True),
- forms.PhoneNumberField('phone', is_required=True),
- ]
+ # User
+ first_name = forms.CharField(max_length=30)
+ last_name = forms.CharField(max_length=30)
+ email = forms.EmailField() # XXX: validator_list=[self.isUniqueEmail])
+ # UserInfo
+ role = forms.ChoiceField(choices=roleChoices)
+ adviser = forms.CharField(max_length=100, required=False)
+ institution = forms.CharField(max_length=100)
+ address1 = forms.CharField(max_length=100)
+ address2 = forms.CharField(max_length=100)
+ address3 = forms.CharField(max_length=100)
+ phone = forms.CharField(max_length=100)
def usernameValidatorList(self):
- return [validators.isAlphaNumeric]
+ return [] #XXX [validators.isAlphaNumeric]
-class RegistrationAddManipulator(RegistrationManipulator):
-
- def __init__(self, request, root):
- super(RegistrationAddManipulator, self).__init__()
+class NewRegistrationForm(ContactForm, PubForm):
+
+ username = forms.CharField(max_length=30) # XXX validator_list=self.usernameValidatorList())
+ password1 = forms.CharField(widget=widgets.PasswordInput, max_length=128)
+ password2 = forms.CharField(widget=widgets.PasswordInput, max_length=128) # XXX , validator_list=[passwordsMatch])
+ # project information
+ projectAbstract = forms.CharField(widget=widgets.Textarea)
+ requestedSUs = forms.IntegerField()
+
+ def __init__(self, request, root, **kwds):
+ super(NewRegistrationForm, self).__init__(**kwds)
self.request = request
self.root = root
- self.fields.extend([
- forms.TextField('username', maxlength=30, is_required=True, validator_list=self.usernameValidatorList()),
- forms.PasswordField('password1', maxlength=128, is_required=True),
- forms.PasswordField('password2', maxlength=128, is_required=True, validator_list=[passwordsMatch]),
- # project information
- forms.LargeTextField('projectAbstract', is_required=True),
- forms.IntegerField('requestedSUs', is_required=True),
- ])
- addPubFields(self.fields)
- def save(self, new_data, inviteCode):
+ def save(self, inviteCode):
# Check the invitation code, if given.
approved = False
@@ -354,6 +358,8 @@
else:
if not invite.hasExpired():
approved = True
+
+ new_data = self.cleaned_data
user, created = User.objects.get_or_create(
username = new_data['username'],
@@ -362,7 +368,7 @@
'email': new_data['email']})
if not created:
# Race: the username was just taken!
- return None, {'username': [usernameTaken]}
+ return None, None, {'username': [usernameTaken]} # XXX: 'errors' can't be dict
# Now we're committed to creating the user account.
user.set_password(new_data['password1'])
@@ -398,27 +404,27 @@
return pubDefaults()
def usernameValidatorList(self):
- validator_list = super(RegistrationAddManipulator, self).usernameValidatorList()
+ validator_list = super(NewRegistrationForm, self).usernameValidatorList()
validator_list.append(isNotExistingUser)
validator_list.append(self.hasCookiesEnabled)
return validator_list
def hasCookiesEnabled(self, field_data, all_data):
if self.request and not self.request.session.test_cookie_worked():
- raise validators.ValidationError, _("Your Web browser doesn't appear to have cookies enabled. Cookies are required for logging in.")
+ raise ValidationError, _("Your Web browser doesn't appear to have cookies enabled. Cookies are required for logging in.")
def isUniqueEmail(self, field_data, all_data):
try:
User.objects.get(email__iexact = field_data)
except User.DoesNotExist:
return
- raise validators.ValidationError(
+ raise ValidationError(
"""Someone has already registered using this e-mail address. """
"""(If you've forgotten your username and/or password, try <a href="%s/pwreset/">resetting your password</a>.)""" % self.root
)
-class RegistrationChangeManipulator(RegistrationManipulator):
+class RegistrationChangeManipulator(object): # XXX (RegistrationManipulator):
def __init__(self, user):
super(RegistrationChangeManipulator, self).__init__()
@@ -456,7 +462,7 @@
return
if u == self.user:
return
- raise validators.ValidationError("Someone has already registered using this e-mail address (but under a different username).")
+ raise ValidationError("Someone has already registered using this e-mail address (but under a different username).")
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -464,7 +470,7 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-class SingleSourceEventAddManipulator(models.Source.AddManipulator):
+class SingleSourceEventAddManipulator(object): # XXX (models.Source.AddManipulator):
def __init__(self):
super(SingleSourceEventAddManipulator, self).__init__()
@@ -473,9 +479,9 @@
del self['event']
del self['dataSource']
del self['region']
- self.fields.extend([forms.TextField('name', maxlength=100, is_required=True),
- forms.TextField('dataSource', maxlength=100, is_required=True),
- forms.TextField('region', maxlength=100, is_required=True),
+ self.fields.extend([forms.TextField('name', max_length=100, is_required=True),
+ forms.TextField('dataSource', max_length=100, is_required=True),
+ forms.TextField('region', max_length=100, is_required=True),
])
return
@@ -518,7 +524,7 @@
return event
-class SingleSourceEventChangeManipulator(models.Source.ChangeManipulator):
+class SingleSourceEventChangeManipulator(object): # XXX (models.Source.ChangeManipulator):
def __init__(self, event):
self.event = event
@@ -530,9 +536,9 @@
del self['event']
del self['dataSource']
del self['region']
- self.fields.extend([forms.TextField('name', maxlength=100, is_required=True),
- forms.TextField('dataSource', maxlength=100, is_required=True),
- forms.TextField('region', maxlength=100, is_required=True),
+ self.fields.extend([forms.TextField('name', max_length=100, is_required=True),
+ forms.TextField('dataSource', max_length=100, is_required=True),
+ forms.TextField('region', max_length=100, is_required=True),
])
return
@@ -569,19 +575,18 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-class UploadManipulator(forms.Manipulator):
+class UploadForm(forms.Form):
+
+ file = forms.FileField()
- def __init__(self, format):
- super(UploadManipulator, self).__init__()
+ def __init__(self, format, **kwds):
+ super(UploadForm, self).__init__(**kwds)
self.format = format
- self.fields = [
- forms.FileUploadField(field_name='file', is_required=True),
- ]
- def get_validation_errors(self, new_data):
+ def xxxget_validation_errors(self, new_data): # XXX
from StringIO import StringIO
- errors = super(UploadManipulator, self).get_validation_errors(new_data)
+ errors = super(UploadForm, self).get_validation_errors(new_data)
if not errors.get('file'):
try:
@@ -593,37 +598,29 @@
return errors
- def save(self, new_data):
+ def save(self):
from StringIO import StringIO
- content = new_data['file']['content']
- stream = StringIO(content)
- return self.format.create(new_data['file']['filename'], stream)
+ uploadedFile = self.cleaned_data['file']
+ stream = StringIO(uploadedFile.read())
+ return self.format.create(uploadedFile.name, stream)
-class LinkManipulator(forms.Manipulator):
-
- def __init__(self, modelClass):
- super(LinkManipulator, self).__init__()
- self.modelClass = modelClass
- self.fields = [
- forms.URLField(field_name='url', is_required=True),
- ]
+def linkFormFactory(modelClass):
+ class LinkForm(forms.Form):
+ url = forms.URLField()
+ def save(self):
+ return modelClass.createLink(self.cleaned_data['url'])
+ return LinkForm
- def flatten_data(self):
- return {}
- def save(self, new_data):
- return self.modelClass.createLink(new_data['url'])
-
-
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# custom form fields
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-class GroupedSelectField(forms.FormField):
+class GroupedSelectField(object): # XXX (forms.FormField):
def __init__(self, field_name, choices=None, size=1, is_required=False,
validator_list=None, member_name=None):
if validator_list is None: validator_list = []
@@ -672,7 +669,7 @@
if str_data == value:
return
str_choices.append(value)
- raise validators.ValidationError, gettext("Select a valid choice; '%(data)s' is not in %(choices)s.") % {'data': str_data, 'choices': str_choices}
+ raise ValidationError, gettext("Select a valid choice; '%(data)s' is not in %(choices)s.") % {'data': str_data, 'choices': str_choices}
# end of file
Modified: cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/management.py
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/management.py 2009-03-23 15:19:28 UTC (rev 14420)
+++ cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/management.py 2009-03-26 03:18:07 UTC (rev 14463)
@@ -1,5 +1,4 @@
-from django.dispatch import dispatcher
from django.db.models import signals
import models
import os
@@ -450,7 +449,7 @@
return
-def createDefaults(app, created_models):
+def createDefaults(app, created_models, **kwds):
flag = False
@@ -462,7 +461,8 @@
specfemModelDir = os.environ.get('WEBPORTAL_3D_MODELS')
if (models.Specfem3DGlobeModel in created_models and
specfemModelDir):
- createSpecfem3DGlobeModels(specfemModelDir)
+ # XXX createSpecfem3DGlobeModels(specfemModelDir)
+ pass
# Mineos
if models.MineosParameters in created_models:
@@ -504,4 +504,4 @@
return
-dispatcher.connect(createDefaults, sender=models, signal=signals.post_syncdb)
+signals.post_syncdb.connect(createDefaults, sender=models)
Modified: cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/mezzanine.py
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/mezzanine.py 2009-03-23 15:19:28 UTC (rev 14420)
+++ cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/mezzanine.py 2009-03-26 03:18:07 UTC (rev 14463)
@@ -1,12 +1,12 @@
-from django import oldforms
+from django import forms
from django.db.models import FileField, ForeignKey
from django.contrib.auth.views import redirect_to_login
from django.template import loader, Context
from django.http import HttpResponse, HttpResponseRedirect, Http404
from django.core.exceptions import ObjectDoesNotExist, PermissionDenied
-from django.core.paginator import ObjectPaginator, InvalidPage
+from django.core.paginator import Paginator, InvalidPage
from django.utils.datastructures import MultiValueDict
from HTMLParser import HTMLParser
@@ -26,13 +26,15 @@
downloadableAsKML = False
duplicatable = True
+ exclude = tuple()
+
views = []
defaultView = 'detail'
@classmethod
def create(cls, request, template_name=None,
template_loader=loader, extra_context=None, post_save_redirect=None,
- login_required=False, manipulator=None):
+ login_required=False, form_class=None):
"""
Generic object-creation function.
@@ -46,29 +48,24 @@
if login_required and not request.user.is_authenticated():
return redirect_to_login(request.path)
- if manipulator is None:
- manipulator = cls.addManipulator(request.user)
+ if form_class is None:
+ form_class = cls.creationFormClass(request.user)
- if request.POST.get('_fromTemplate'):
- errors = {}
- new_data = MultiValueDict()
- new_data.update(manipulator.flatten_data())
- new_data.update(request.POST.copy())
+ if request.POST.get('_fromTemplate'): # XXX
+ #new_data = MultiValueDict()
+ #new_data.update(manipulator.flatten_data())
+ #new_data.update(request.POST.copy())
- elif request.POST:
+ form = form_class(data = request.POST, files = request.FILES)
+
+ elif request.method == "POST":
# If data was POSTed, we're trying to create a new object
- new_data = request.POST.copy()
+ form = form_class(data = request.POST, files = request.FILES)
- if model._meta.has_field_type(FileField):
- new_data.update(request.FILES)
-
# Check for errors
- errors = manipulator.get_validation_errors(new_data)
- manipulator.do_html2python(new_data)
-
- if not errors:
+ if form.is_valid():
# No errors -- this means we can save the data!
- new_object = manipulator.save(new_data)
+ new_object = form.save()
models.Ownership.objects.create(owner = request.user, obj = new_object)
@@ -86,11 +83,9 @@
else:
# No POST, so we want a brand new form without any data or errors
- errors = {}
- new_data = manipulator.flatten_data()
+ form = form_class()
- # Create the FormWrapper, template, context, response
- form = oldforms.FormWrapper(manipulator, new_data, errors)
+ # Create template, context, response
if not template_name:
template_name = "%s/%s_form.html" % (model._meta.app_label, model._meta.object_name.lower())
t = template_loader.get_template(template_name)
@@ -128,17 +123,11 @@
model = self.Model
object = self.obj
- manipulator = self.changeManipulator(request.user)
+ if request.method == "POST":
+ form = self.updateForm(request)
+ if form.is_valid():
+ object = form.save()
- if request.POST:
- new_data = request.POST.copy()
- if model._meta.has_field_type(FileField):
- new_data.update(request.FILES)
- errors = manipulator.get_validation_errors(new_data)
- manipulator.do_html2python(new_data)
- if not errors:
- object = manipulator.save(new_data)
-
if request.user.is_authenticated():
request.user.message_set.create(message = 'Saved "%s".' % object)
@@ -150,11 +139,8 @@
else:
return HttpResponseRedirect(self.urlForObject(self, request.root))
else:
- errors = {}
- # This makes sure the form acurate represents the fields of the place.
- new_data = manipulator.flatten_data()
+ form = self.updateForm()
- form = oldforms.FormWrapper(manipulator, new_data, errors)
if not template_name:
template_name = "%s/%s_form.html" % (model._meta.app_label, model._meta.object_name.lower())
t = template_loader.get_template(template_name)
@@ -262,7 +248,7 @@
if extra_context is None: extra_context = {}
if paginate_by:
- paginator = ObjectPaginator(l, paginate_by)
+ paginator = Paginator(l, paginate_by)
if not page:
page = request.GET.get('page', 1)
try:
@@ -376,19 +362,14 @@
@classmethod
def upload(cls, request, template_loader=loader, post_save_redirect=None):
- from forms import UploadManipulator
+ from forms import UploadForm
ModelClass = cls.Model
- manipulator = UploadManipulator(cls.FileFormat())
-
- if request.method == 'POST':
- new_data = request.POST.copy()
- new_data.update(request.FILES)
- errors = manipulator.get_validation_errors(new_data)
- if not errors:
- manipulator.do_html2python(new_data)
- new_object = manipulator.save(new_data)
+ if request.method == "POST":
+ form = UploadForm(cls.FileFormat(), data = request.POST, files = request.FILES)
+ if form.is_valid():
+ new_object = form.save()
models.Ownership.objects.create(owner = request.user, obj = new_object)
if request.user.is_authenticated():
request.user.message_set.create(message = 'Uploaded "%s".' % new_object)
@@ -399,9 +380,8 @@
else:
return HttpResponseRedirect(cls.urlForObject(new_object, request.root))
else:
- errors = new_data = {}
+ form = UploadForm(cls.FileFormat())
- form = oldforms.FormWrapper(manipulator, new_data, errors)
template_name = "%s/%s_upload.html" % (ModelClass._meta.app_label, ModelClass._meta.object_name.lower())
t = template_loader.get_template(template_name)
c = Context({
@@ -413,13 +393,13 @@
@classmethod
def link(cls, request, **kwds):
- from forms import LinkManipulator
+ from forms import linkFormFactory
model = cls.Model
+ LinkForm = linkFormFactory(model)
template_name = "%s/%s_link.html" % (model._meta.app_label, model._meta.object_name.lower())
- manipulator = LinkManipulator(model)
return cls.create(request,
template_name=template_name,
- manipulator=manipulator,
+ form_class=LinkForm,
**kwds)
id = property(lambda self: self.obj.id)
@@ -447,6 +427,22 @@
cls.replaceForeignKeyFields(manipulator, user)
return manipulator
+ @classmethod
+ def creationFormClass(cls, user): # XXX ???
+ class CreationForm(forms.ModelForm):
+ class Meta:
+ model = cls.Model
+ return CreationForm
+
+ def updateForm(self, request=None):
+ class EditForm(forms.ModelForm):
+ class Meta:
+ model = self.Model
+ exclude = self.exclude
+ if request is None:
+ return EditForm(instance = self.obj)
+ return EditForm(instance = self.obj, data = request.POST, files = request.FILES)
+
def changeManipulator(self, user):
object = self.obj
manipulator = self.Model.ChangeManipulator(getattr(object, object._meta.pk.attname))
@@ -473,7 +469,7 @@
# Create a new, custom SelectField for this ForeignKey.
objList, builtInCount = field.rel.to.userObjectList(user)
- fields.append(oldforms.SelectField(
+ fields.append(forms.SelectField(
field.name,
is_required = True,
choices = blank + [(obj.id, str(obj)) for obj in objList],
@@ -813,6 +809,8 @@
duplicatable = False
downloadableAsTarGz = True
+ exclude = ('pathname', 'description', 'url')
+
def changeManipulator(self, user):
object = self.obj
return self.Model.ChangeManipulator(getattr(object, object._meta.pk.attname), follow = dict(pathname = False))
@@ -871,9 +869,7 @@
downloadableAsText = True
duplicatable = False
- def changeManipulator(self, user):
- object = self.obj
- return self.Model.ChangeManipulator(getattr(object, object._meta.pk.attname), follow = dict(data = False))
+ exclude = ('data',)
def downloadAsText(self, request):
response = HttpResponse(mimetype='text/plain')
Modified: cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/models.py
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/models.py 2009-03-23 15:19:28 UTC (rev 14420)
+++ cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/models.py 2009-03-26 03:18:07 UTC (rev 14463)
@@ -2,7 +2,8 @@
from django.db import models
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
-from django.core import validators
+from django.contrib.contenttypes.generic import GenericForeignKey
+from django.core.exceptions import ValidationError
import cmt
import datetime
@@ -13,7 +14,7 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-class Model(models.Model):
+class Model(object):
@classmethod
def contentType(cls):
@@ -91,19 +92,19 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-class Region(Model):
- name = models.CharField(maxlength=100, primary_key=True)
+class Region(models.Model, Model):
+ name = models.CharField(max_length=100, primary_key=True)
def __str__(self): return self.name
-class DataSource(Model):
- name = models.CharField(maxlength=100, primary_key=True)
+class DataSource(models.Model, Model):
+ name = models.CharField(max_length=100, primary_key=True)
def __str__(self): return self.name
-class Event(Model, MaybeArchival):
+class Event(models.Model, Model, MaybeArchival):
- name = models.CharField(maxlength=100)
+ name = models.CharField(max_length=100)
def _getSingleSource(self):
if not hasattr(self, '_singleSource'):
@@ -140,7 +141,7 @@
return
-class Source(Model):
+class Source(models.Model, Model):
# an event is composed of one or more sources
event = models.ForeignKey(Event, db_index=True)
@@ -150,25 +151,25 @@
when = models.DateTimeField()
microsecond = models.IntegerField()
- sourceLatitude = models.FloatField(max_digits=19, decimal_places=10)
- sourceLongitude = models.FloatField(max_digits=19, decimal_places=10)
- sourceDepth = models.FloatField(max_digits=19, decimal_places=10)
- sourceMB = models.FloatField(max_digits=19, decimal_places=10)
- sourceMs = models.FloatField(max_digits=19, decimal_places=10)
+ sourceLatitude = models.FloatField()
+ sourceLongitude = models.FloatField()
+ sourceDepth = models.FloatField()
+ sourceMB = models.FloatField()
+ sourceMs = models.FloatField()
region = models.ForeignKey(Region)
- eventName = models.CharField(maxlength=100)
- timeShift = models.FloatField(max_digits=19, decimal_places=10, db_index=True)
- halfDuration = models.FloatField(max_digits=19, decimal_places=10)
- latitude = models.FloatField(max_digits=19, decimal_places=10)
- longitude = models.FloatField(max_digits=19, decimal_places=10)
- depth = models.FloatField(max_digits=19, decimal_places=10)
- Mrr = models.FloatField(max_digits=40, decimal_places=10)
- Mtt = models.FloatField(max_digits=40, decimal_places=10)
- Mpp = models.FloatField(max_digits=40, decimal_places=10)
- Mrt = models.FloatField(max_digits=40, decimal_places=10)
- Mrp = models.FloatField(max_digits=40, decimal_places=10)
- Mtp = models.FloatField(max_digits=40, decimal_places=10)
+ eventName = models.CharField(max_length=100)
+ timeShift = models.FloatField(db_index=True)
+ halfDuration = models.FloatField()
+ latitude = models.FloatField()
+ longitude = models.FloatField()
+ depth = models.FloatField()
+ Mrr = models.FloatField()
+ Mtt = models.FloatField()
+ Mpp = models.FloatField()
+ Mrt = models.FloatField()
+ Mrp = models.FloatField()
+ Mtp = models.FloatField()
def __str__(self): return self.eventName
@@ -274,17 +275,17 @@
saveSource = classmethod(saveSource)
-class ArchivedSource(Model):
- halfDuration = models.FloatField(max_digits=19, decimal_places=10)
- latitude = models.FloatField(max_digits=19, decimal_places=10, db_index=True)
- longitude = models.FloatField(max_digits=19, decimal_places=10, db_index=True)
- depth = models.FloatField(max_digits=19, decimal_places=10)
- Mrr = models.FloatField(max_digits=19, decimal_places=10)
- Mtt = models.FloatField(max_digits=19, decimal_places=10)
- Mpp = models.FloatField(max_digits=19, decimal_places=10)
- Mrt = models.FloatField(max_digits=19, decimal_places=10)
- Mrp = models.FloatField(max_digits=19, decimal_places=10)
- Mtp = models.FloatField(max_digits=19, decimal_places=10)
+class ArchivedSource(models.Model, Model):
+ halfDuration = models.FloatField()
+ latitude = models.FloatField(db_index=True)
+ longitude = models.FloatField(db_index=True)
+ depth = models.FloatField()
+ Mrr = models.FloatField()
+ Mtt = models.FloatField()
+ Mpp = models.FloatField()
+ Mrt = models.FloatField()
+ Mrp = models.FloatField()
+ Mtp = models.FloatField()
def iterCMTSolutions(self):
cmtSolution = cmt.CMTSolution()
@@ -303,16 +304,16 @@
)
-class StationNetwork(Model):
- code = models.CharField(maxlength=10, primary_key=True) # 3-5 chars currently
- name = models.CharField(maxlength=100)
+class StationNetwork(models.Model, Model):
+ code = models.CharField(max_length=10, primary_key=True) # 3-5 chars currently
+ name = models.CharField(max_length=100)
def __str__(self): return self.code
-class StationList(Model, ImmutableObject):
+class StationList(models.Model, Model, ImmutableObject):
- name = models.CharField(maxlength=100)
+ name = models.CharField(max_length=100)
def __str__(self): return self.name
@@ -321,19 +322,19 @@
super(StationList, self).delete()
-class Station(Model):
+class Station(models.Model, Model):
# each user has their own stations
stationList = models.ForeignKey(StationList, db_index=True)
- code = models.CharField(maxlength=10) # 3-4 chars currently
- name = models.CharField(maxlength=100)
+ code = models.CharField(max_length=10) # 3-4 chars currently
+ name = models.CharField(max_length=100)
network = models.ForeignKey(StationNetwork, null=True)
status = models.IntegerField(choices=STATION_STATUS_TYPES, default=1)
- latitude = models.FloatField(max_digits=19, decimal_places=10)
- longitude = models.FloatField(max_digits=19, decimal_places=10)
- elevation = models.FloatField(max_digits=19, decimal_places=10)
- bur = models.FloatField(max_digits=19, decimal_places=10, default=0.0)
+ latitude = models.FloatField()
+ longitude = models.FloatField()
+ elevation = models.FloatField()
+ bur = models.FloatField(default=0.0)
def __str__(self): return self.code
@@ -365,31 +366,29 @@
nproc = 1
nex_c = 1
if (8 * nex_c * nproc % 16 != 0):
- raise validators.ValidationError, "This product must be a multiple of 16."
+ raise ValidationError, "This product must be a multiple of 16."
return
return isValidNexC
-class Specfem3DGlobeMesh(Model, EditableObject):
+class Specfem3DGlobeMesh(models.Model, Model, EditableObject):
- name = models.CharField(maxlength=100)
+ name = models.CharField(max_length=100)
- nchunks = models.IntegerField(core=True, choices=NCHUNKS_CHOICES, default=1)
- nproc_xi = models.IntegerField(core=True, choices=NPROC_CHOICES, default=5)
- nproc_eta = models.IntegerField(core=True, choices=NPROC_CHOICES, default=5)
- nex_xi_c = models.IntegerField(core=True, choices=NEX_C_CHOICES, default=2,
- validator_list=[nexValidator('nproc_xi')])
- nex_eta_c = models.IntegerField(core=True, choices=NEX_C_CHOICES, default=2,
- validator_list=[nexValidator('nproc_eta')])
+ nchunks = models.IntegerField(choices=NCHUNKS_CHOICES, default=1)
+ nproc_xi = models.IntegerField(choices=NPROC_CHOICES, default=5)
+ nproc_eta = models.IntegerField(choices=NPROC_CHOICES, default=5)
+ nex_xi_c = models.IntegerField(choices=NEX_C_CHOICES, default=2) # XXX: validator_list=[nexValidator('nproc_xi')]
+ nex_eta_c = models.IntegerField(choices=NEX_C_CHOICES, default=2) # XXX: validator_list=[nexValidator('nproc_eta')]
def nex_xi(self): return 8 * self.nex_xi_c * self.nproc_xi
def nex_eta(self): return 8 * self.nex_eta_c * self.nproc_eta
# this is for regional only (when type == 2), and when global, all these values are fixed
- angular_width_eta = models.FloatField(max_digits=19, decimal_places=10, core=True)
- angular_width_xi = models.FloatField(max_digits=19, decimal_places=10, core=True)
- center_latitude = models.FloatField(max_digits=19, decimal_places=10, core=True)
- center_longitude = models.FloatField(max_digits=19, decimal_places=10, core=True)
- gamma_rotation_azimuth = models.FloatField(max_digits=19, decimal_places=10, core=True)
+ angular_width_eta = models.FloatField()
+ angular_width_xi = models.FloatField()
+ center_latitude = models.FloatField()
+ center_longitude = models.FloatField()
+ gamma_rotation_azimuth = models.FloatField()
def __str__(self): return self.name
@@ -402,9 +401,9 @@
nproc = property(lambda self: self.nchunks * self.nproc_xi * self.nproc_eta)
-class Specfem3DGlobeModel(Model, EditableObject):
+class Specfem3DGlobeModel(models.Model, Model, EditableObject):
- name = models.CharField(maxlength=100)
+ name = models.CharField(max_length=100)
pathname = models.FileField(upload_to="SeismoWebPortal/models/3D", blank=True)
description = models.TextField(blank=True)
@@ -413,7 +412,6 @@
def __str__(self): return self.name
def list(self, verbose=True):
- from django.core.validators import isValidURL
import tarfile, time
from StringIO import StringIO
@@ -456,18 +454,18 @@
createLink = classmethod(createLink)
-class Specfem3DGlobeParameters(Model, EditableObject):
+class Specfem3DGlobeParameters(models.Model, Model, EditableObject):
- name = models.CharField(maxlength=100)
+ name = models.CharField(max_length=100)
mesh = models.ForeignKey(Specfem3DGlobeMesh)
model = models.ForeignKey(Specfem3DGlobeModel)
- oceans = models.BooleanField(core=True, default=True)
- gravity = models.BooleanField(core=True, default=True)
- attenuation = models.BooleanField(core=True, default=True)
- topography = models.BooleanField(core=True, default=True)
- rotation = models.BooleanField(core=True, default=True)
- ellipticity = models.BooleanField(core=True, default=True)
+ oceans = models.BooleanField(default=True)
+ gravity = models.BooleanField(default=True)
+ attenuation = models.BooleanField(default=True)
+ topography = models.BooleanField(default=True)
+ rotation = models.BooleanField(default=True)
+ ellipticity = models.BooleanField(default=True)
def __str__(self): return self.name
@@ -523,23 +521,23 @@
# Mineos
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-class MineosModeCatalog(Model, EditableObject):
+class MineosModeCatalog(models.Model, Model, EditableObject):
- name = models.CharField(maxlength=100)
+ name = models.CharField(max_length=100)
#------------------------------------------------------------------------
# minos_bran
- eps = models.FloatField(max_digits=19, decimal_places=10, default=1.0e-10)
- wgrav = models.FloatField(max_digits=19, decimal_places=10, default=1.0) # mHz
+ eps = models.FloatField(default=1.0e-10)
+ wgrav = models.FloatField(default=1.0) # mHz
# angular orders
lmin = models.IntegerField(default=2)
lmax = models.IntegerField(default=8000)
# compute frequency range
- wmin = models.FloatField(max_digits=19, decimal_places=10, default=0.0) # mHz
- wmax = models.FloatField(max_digits=19, decimal_places=10, default=200.0) # mHz
+ wmin = models.FloatField(default=0.0) # mHz
+ wmax = models.FloatField(default=200.0) # mHz
# dispersion branch numbers
nmin = models.IntegerField(default=0)
@@ -549,14 +547,14 @@
#------------------------------------------------------------------------
# eigcon
- max_depth = models.FloatField(max_digits=19, decimal_places=10, default=1000.0) # km
+ max_depth = models.FloatField(default=1000.0) # km
def __str__(self): return self.name
-class MineosModel(Model, ImmutableObject):
+class MineosModel(models.Model, Model, ImmutableObject):
- name = models.CharField(maxlength=100)
+ name = models.CharField(max_length=100)
# A Mineos model is a small (15-20K) text file.
data = models.TextField()
@@ -571,9 +569,9 @@
)
-class MineosParameters(Model, EditableObject):
+class MineosParameters(models.Model, Model, EditableObject):
- name = models.CharField(maxlength=100)
+ name = models.CharField(max_length=100)
catalog = models.ForeignKey(MineosModeCatalog)
model = models.ForeignKey(MineosModel)
@@ -587,13 +585,13 @@
#------------------------------------------------------------------------
# green
- fmin = models.FloatField(max_digits=19, decimal_places=10, default=10.0) # mHz
- fmax = models.FloatField(max_digits=19, decimal_places=10, default=260.0) # mHz
+ fmin = models.FloatField(default=10.0) # mHz
+ fmax = models.FloatField(default=260.0) # mHz
#------------------------------------------------------------------------
# syndat
- step = models.FloatField(max_digits=19, decimal_places=10, default=1.0) # seconds
+ step = models.FloatField(default=1.0) # seconds
datatype = models.IntegerField(choices=DATATYPE_CHOICES, default=0)
def __str__(self): return self.name
@@ -626,24 +624,23 @@
number = float(field_data)
if lower < number and number <= upper:
return
- raise validators.ValidationError("Please enter a positive number between %.1f and %.1f." % (lower, upper))
+ raise ValidationError("Please enter a positive number between %.1f and %.1f." % (lower, upper))
-class ArchivedRun(Model):
+class ArchivedRun(models.Model, Model):
eventType = models.ForeignKey(ContentType, db_index=True, related_name='archivedrun_event_set')
eventId = models.PositiveIntegerField(db_index=True)
- event = models.GenericForeignKey(ct_field='eventType', fk_field='eventId')
+ event = GenericForeignKey(ct_field='eventType', fk_field='eventId')
stationList = models.ForeignKey(StationList)
parametersType = models.ForeignKey(ContentType, db_index=True, related_name='archivedrun_parameters_set')
parametersId = models.PositiveIntegerField(db_index=True)
- parameters = models.GenericForeignKey(ct_field='parametersType', fk_field='parametersId')
+ parameters = GenericForeignKey(ct_field='parametersType', fk_field='parametersId')
- record_length = models.FloatField(max_digits=19, decimal_places=10, default=20.0,
- validator_list=[isValidRecordLength])
+ record_length = models.FloatField(default=20.0) # XXX: validator_list=[isValidRecordLength]
- status = models.CharField(maxlength=100)
+ status = models.CharField(max_length=100)
started = models.DateTimeField(auto_now_add=True, editable=False)
finished = models.DateTimeField(null=True)
@@ -664,16 +661,15 @@
return self.parameters.estimatedCost(self)
-class Run(Model):
+class Run(models.Model, Model):
event = models.ForeignKey(Event)
stationList = models.ForeignKey(StationList)
parametersType = models.ForeignKey(ContentType, db_index=True)
parametersId = models.PositiveIntegerField(db_index=True)
- parameters = models.GenericForeignKey(ct_field='parametersType', fk_field='parametersId')
+ parameters = GenericForeignKey(ct_field='parametersType', fk_field='parametersId')
- record_length = models.FloatField(max_digits=19, decimal_places=10, default=20.0,
- validator_list=[isValidRecordLength])
+ record_length = models.FloatField(default=20.0) # XXX: validator_list=[isValidRecordLength]
zero_half_duration = models.BooleanField(default=True)
isDraft = models.BooleanField(default=True)
@@ -810,13 +806,13 @@
return pb < 0
-class Job(Model):
+class Job(models.Model, Model):
# each run may correspond to multiple jobs
run = models.ForeignKey(ArchivedRun)
- task = models.CharField(maxlength=100)
- status = models.CharField(maxlength=100)
- progress = models.FloatField(max_digits=19, decimal_places=10, default=-1.0)
+ task = models.CharField(max_length=100)
+ status = models.CharField(max_length=100)
+ progress = models.FloatField(default=-1.0)
created = models.DateTimeField(auto_now_add=True, editable=False)
started = models.DateTimeField(null=True, blank=True)
@@ -845,10 +841,10 @@
return offset
-class OutputFile(Model):
+class OutputFile(models.Model, Model):
job = models.ForeignKey(Job)
- name = models.CharField(maxlength=100)
+ name = models.CharField(max_length=100)
def url(self): return self.job.url + self.name
@@ -858,13 +854,13 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-class Cluster(Model):
- name = models.CharField(maxlength=100)
+class Cluster(models.Model, Model):
+ name = models.CharField(max_length=100)
url = models.URLField(verify_exists=False)
- daemonCode = models.CharField(maxlength=100)
+ daemonCode = models.CharField(max_length=100)
lastAccess = models.DateTimeField(null=True, blank=True)
- reportedStatus = models.CharField(maxlength=100)
+ reportedStatus = models.CharField(max_length=100)
queueWaitTime = models.IntegerField(default=-1) # in minutes
# cluster selection algorithm
@@ -873,7 +869,7 @@
# conversion factor from CPU hours to TeraGrid wide roaming SUs
# http://www.teragrid.org/userinfo/access/convert.php
- suFactor = models.FloatField(max_digits=19, decimal_places=10)
+ suFactor = models.FloatField()
def __str__(self): return self.name
@@ -919,16 +915,16 @@
return clusters[0]
-class Specfem3DGlobePerformance(Model):
+class Specfem3DGlobePerformance(models.Model, Model):
cluster = models.ForeignKey(Cluster)
mesh = models.ForeignKey(Specfem3DGlobeMesh)
- overhead = models.FloatField(max_digits=19, decimal_places=10)
- timeFactor = models.FloatField(max_digits=19, decimal_places=10)
- stationFactor = models.FloatField(max_digits=19, decimal_places=10)
+ overhead = models.FloatField()
+ timeFactor = models.FloatField()
+ stationFactor = models.FloatField()
-class Award(Model):
+class Award(models.Model, Model):
user = models.ForeignKey(User, null=True, blank=True) # null = all users
amount = models.IntegerField() # in SUs
description = models.TextField(blank=True)
@@ -941,9 +937,9 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-class Invite(Model):
- code = models.CharField(maxlength=100, unique=True, db_index=True)
- name = models.CharField(maxlength=100)
+class Invite(models.Model, Model):
+ code = models.CharField(max_length=100, unique=True, db_index=True)
+ name = models.CharField(max_length=100)
description = models.TextField(blank=True)
created = models.DateTimeField(auto_now_add=True, editable=False)
modified = models.DateTimeField(auto_now=True, editable=False)
@@ -969,16 +965,16 @@
(5, 'other'),
)
-class UserInfo(Model):
+class UserInfo(models.Model, Model):
user = models.OneToOneField(User)
- institution = models.CharField(maxlength=100)
- address1 = models.CharField(maxlength=100)
- address2 = models.CharField(maxlength=100)
- address3 = models.CharField(maxlength=100)
- phone = models.PhoneNumberField()
+ institution = models.CharField(max_length=100)
+ address1 = models.CharField(max_length=100)
+ address2 = models.CharField(max_length=100)
+ address3 = models.CharField(max_length=100)
+ phone = models.CharField(max_length=100)
role = models.IntegerField(choices=ROLE_CHOICES)
- adviser = models.CharField(maxlength=100, blank=True)
+ adviser = models.CharField(max_length=100, blank=True)
# the invitation used, if any
invite = models.ForeignKey(Invite, null=True, blank=True)
@@ -1035,25 +1031,25 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-class Ownership(Model):
+class Ownership(models.Model, Model):
owner = models.ForeignKey(User, db_index=True)
objType = models.ForeignKey(ContentType, db_index=True)
objId = models.PositiveIntegerField(db_index=True)
- obj = models.GenericForeignKey(ct_field='objType', fk_field='objId')
+ obj = GenericForeignKey(ct_field='objType', fk_field='objId')
-class BuiltIn(Model):
+class BuiltIn(models.Model, Model):
objType = models.ForeignKey(ContentType, db_index=True)
objId = models.PositiveIntegerField(db_index=True)
- obj = models.GenericForeignKey(ct_field='objType', fk_field='objId')
+ obj = GenericForeignKey(ct_field='objType', fk_field='objId')
-class Archive(Model):
+class Archive(models.Model, Model):
objType = models.ForeignKey(ContentType, db_index=True)
objId = models.PositiveIntegerField(db_index=True)
- obj = models.GenericForeignKey(ct_field='objType', fk_field='objId')
+ obj = GenericForeignKey(ct_field='objType', fk_field='objId')
# end of file
Modified: cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/sql/stationnetwork.sql
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/sql/stationnetwork.sql 2009-03-23 15:19:28 UTC (rev 14420)
+++ cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/sql/stationnetwork.sql 2009-03-26 03:18:07 UTC (rev 14463)
@@ -56,7 +56,7 @@
INSERT INTO SeismoWebPortal_stationnetwork (code, name) VALUES ('CAT', 'Istituto Scienze della Terra, Catania, Italy');
UPDATE SeismoWebPortal_stationnetwork SET name = 'China Digital Broadband Seismic Network (CDSN), Beijing, China' WHERE code = 'CD';
INSERT INTO SeismoWebPortal_stationnetwork (code, name) VALUES ('CDMG', 'California Division of Mines and Geology, Sacramento, USA');
-INSERT INTO SeismoWebPortal_stationnetwork (code, name) VALUES ('CDPJ', 'Nat. Research Ctr for Disaster Prevention, Ibaraki-ken, Japan--now NIED');
+INSERT INTO SeismoWebPortal_stationnetwork (code, name) VALUES ('CDPJ', 'Nat. Research Ctr for Disaster Prevention, Ibaraki-ken, Japan (now NIED)');
INSERT INTO SeismoWebPortal_stationnetwork (code, name) VALUES ('CDR', 'Commissariat a l''Energie Atomique (CEA), Fontenay aux Roses, France');
INSERT INTO SeismoWebPortal_stationnetwork (code, name) VALUES ('CDWR', 'California Department of Water Resources, Sacramento, USA');
INSERT INTO SeismoWebPortal_stationnetwork (code, name) VALUES ('CELS', 'Comisiidroelectrica del Rio Lempa, El Salvador');
@@ -187,7 +187,7 @@
INSERT INTO SeismoWebPortal_stationnetwork (code, name) VALUES ('LIM', 'Instituto Geofco del Perma, Peru');
INSERT INTO SeismoWebPortal_stationnetwork (code, name) VALUES ('LJC', 'Inst. of Geop. and Planet. Phys., UC San Diego, La Jolla, Calif, USA');
INSERT INTO SeismoWebPortal_stationnetwork (code, name) VALUES ('LJU', 'ARSO, Urad za seizmologijo, Ljubljana, Slovenia');
-INSERT INTO SeismoWebPortal_stationnetwork (code, name) VALUES ('LLI', 'Istituto Internazionale di Vulcanologia--CNR, Catania, Italy');
+INSERT INTO SeismoWebPortal_stationnetwork (code, name) VALUES ('LLI', 'Istituto Internazionale di Vulcanologia (CNR), Catania, Italy');
INSERT INTO SeismoWebPortal_stationnetwork (code, name) VALUES ('LMM', 'Servico Meteorologico de Mobique, Maputo, Mozambique (closed)');
INSERT INTO SeismoWebPortal_stationnetwork (code, name) VALUES ('LOA', 'Los Alamos Scientific Laboratories, Los Alamos, New Mexico, USA');
INSERT INTO SeismoWebPortal_stationnetwork (code, name) VALUES ('LPA', 'Observatorio Astronomico, Universidad Nacional de La Plata, Argentina');
@@ -280,7 +280,7 @@
INSERT INTO SeismoWebPortal_stationnetwork (code, name) VALUES ('RSPR', 'Red Sica de Puerto Rico, Universidad de Puerto Rico, Mayag');
INSERT INTO SeismoWebPortal_stationnetwork (code, name) VALUES ('RUVS', 'Rede Universitaria de Vigilancia Sismovulcanica, SMiguel, Azores');
INSERT INTO SeismoWebPortal_stationnetwork (code, name) VALUES ('RYD', 'King Saud University, Riyadh, Saudi Arabia');
-INSERT INTO SeismoWebPortal_stationnetwork (code, name) VALUES ('SAKL', 'Sakhalin Complex Research Institute, Novoalexandrovsk -- now SKHL net');
+INSERT INTO SeismoWebPortal_stationnetwork (code, name) VALUES ('SAKL', 'Sakhalin Complex Research Institute, Novoalexandrovsk (now SKHL net)');
INSERT INTO SeismoWebPortal_stationnetwork (code, name) VALUES ('SAND', 'Sandia Laboratories, Albuquerque, New Mexico, USA');
INSERT INTO SeismoWebPortal_stationnetwork (code, name) VALUES ('SAPN', 'Emergency Management Office, Saipan, Northern Mariana Islands');
INSERT INTO SeismoWebPortal_stationnetwork (code, name) VALUES ('SBS', 'Institut National de la Morologie, Tunis, Tunisia');
@@ -348,7 +348,7 @@
INSERT INTO SeismoWebPortal_stationnetwork (code, name) VALUES ('USAV', 'USGS Alaska Volcano Observatory, Anchorage, USA');
INSERT INTO SeismoWebPortal_stationnetwork (code, name) VALUES ('USBR', 'US Bureau of Reclamation, Denver, Colorado, USA');
INSERT INTO SeismoWebPortal_stationnetwork (code, name) VALUES ('USC', 'University of Southern California, Los Angeles, USA');
-INSERT INTO SeismoWebPortal_stationnetwork (code, name) VALUES ('USGS', 'US Geological Survey--other than ABQ, AGS, MNLO, NEIC, HVO and USAVO');
+INSERT INTO SeismoWebPortal_stationnetwork (code, name) VALUES ('USGS', 'US Geological Survey (other than ABQ, AGS, MNLO, NEIC, HVO and USAVO)');
INSERT INTO SeismoWebPortal_stationnetwork (code, name) VALUES ('UTSU', 'Utsunomiya University, Japan');
INSERT INTO SeismoWebPortal_stationnetwork (code, name) VALUES ('UVC', 'Universidad del Valle, Cali, Colombia');
INSERT INTO SeismoWebPortal_stationnetwork (code, name) VALUES ('UZBK', 'Institute of Seismology, Uzbekistan Academy of Sciences, Tashkent');
Modified: cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/cluster_queueWaitTime_form.html
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/cluster_queueWaitTime_form.html 2009-03-23 15:19:28 UTC (rev 14420)
+++ cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/cluster_queueWaitTime_form.html 2009-03-26 03:18:07 UTC (rev 14463)
@@ -7,8 +7,8 @@
<h1>Queue Wait Time</h1>
- {% if form.has_errors %}
- <p>{{ form.error_dict }}
+ {% if form.errors %}
+ <p>{{ form.errors }}
{% endif %}
<form method="post" action="{{ action }}">
Modified: cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/cpu_time_request_form.html
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/cpu_time_request_form.html 2009-03-23 15:19:28 UTC (rev 14420)
+++ cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/cpu_time_request_form.html 2009-03-26 03:18:07 UTC (rev 14463)
@@ -7,8 +7,8 @@
<h2>Profile → Request CPU Time</h2>
-{% if form.has_errors %}
-<p><span class=error>Please correct the following error{{ form.error_dict|pluralize }}.</span>
+{% if form.errors %}
+<p><span class=error>Please correct the following error{{ form.errors|pluralize }}.</span>
{% endif %}
<form method="post" action="{{action}}" enctype="multipart/form-data">
Modified: cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/event_form.html
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/event_form.html 2009-03-23 15:19:28 UTC (rev 14420)
+++ cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/event_form.html 2009-03-26 03:18:07 UTC (rev 14463)
@@ -1,8 +1,8 @@
<h2>Rename Event</h2>
-{% if form.has_errors %}
-<p><span class=error>Please correct the following error{{ form.error_dict|pluralize }}.</span>
+{% if form.errors %}
+<p><span class=error>Please correct the following error{{ form.errors|pluralize }}.</span>
{% endif %}
<form method="post" action="{{action}}">
Modified: cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/event_search.html
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/event_search.html 2009-03-23 15:19:28 UTC (rev 14420)
+++ cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/event_search.html 2009-03-26 03:18:07 UTC (rev 14463)
@@ -1,8 +1,8 @@
<h2>Event Search</h2>
-{% if form.has_errors %}
-<p><span class=error>Please correct the following error{{ form.error_dict|pluralize }}.</span>
+{% if form.errors %}
+<p><span class=error>Please correct the following error{{ form.errors|pluralize }}.</span>
{% else %}
<a href="http://www.globalcmt.org/">Powered by the Global CMT Project.</a>
{% endif %}
Modified: cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/event_upload.html
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/event_upload.html 2009-03-23 15:19:28 UTC (rev 14420)
+++ cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/event_upload.html 2009-03-26 03:18:07 UTC (rev 14463)
@@ -5,8 +5,8 @@
<input type="hidden" name="class" value="Event">
<input type="hidden" name="action" value="upload">
- {% if form.has_errors %}
- <p><span class=error>Please correct the following error{{ form.error_dict|pluralize }}.</span>
+ {% if form.errors %}
+ <p><span class=error>Please correct the following error{{ form.errors|pluralize }}.</span>
{% endif %}
<div class=tab30ex>
Modified: cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/job_form.html
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/job_form.html 2009-03-23 15:19:28 UTC (rev 14420)
+++ cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/job_form.html 2009-03-26 03:18:07 UTC (rev 14463)
@@ -7,8 +7,8 @@
<h1>Job</h1>
- {% if form.has_errors %}
- <p>{{ form.error_dict }}
+ {% if form.errors %}
+ <p>{{ form.errors }}
{% endif %}
<form method="post" action="{{action}}">
Modified: cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/job_progress_form.html
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/job_progress_form.html 2009-03-23 15:19:28 UTC (rev 14420)
+++ cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/job_progress_form.html 2009-03-26 03:18:07 UTC (rev 14463)
@@ -7,8 +7,8 @@
<h1>Job Progress</h1>
- {% if form.has_errors %}
- <p>{{ form.error_dict }}
+ {% if form.errors %}
+ <p>{{ form.errors }}
{% endif %}
<form method="post" action="{{ action }}">
Modified: cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/mesh_form_base.html
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/mesh_form_base.html 2009-03-23 15:19:28 UTC (rev 14420)
+++ cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/mesh_form_base.html 2009-03-26 03:18:07 UTC (rev 14463)
@@ -10,8 +10,8 @@
<input type="hidden" name="action" value="new">
{% endif %}
- {% if form.has_errors %}
- <p><span class=error>Please correct the following error{{ form.error_dict|pluralize }}.</span>
+ {% if form.errors %}
+ <p><span class=error>Please correct the following error{{ form.errors|pluralize }}.</span>
{% endif %}
<div class=tab30ex>
Modified: cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/mineosmodecatalog_form.html
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/mineosmodecatalog_form.html 2009-03-23 15:19:28 UTC (rev 14420)
+++ cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/mineosmodecatalog_form.html 2009-03-26 03:18:07 UTC (rev 14463)
@@ -10,8 +10,8 @@
<input type="hidden" name="action" value="new">
{% endif %}
- {% if form.has_errors %}
- <p><span class=error>Please correct the following error{{ form.error_dict|pluralize }}.</span>
+ {% if form.errors %}
+ <p><span class=error>Please correct the following error{{ form.errors|pluralize }}.</span>
{% endif %}
<div class=tab30ex>
Modified: cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/mineosmodel_form.html
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/mineosmodel_form.html 2009-03-23 15:19:28 UTC (rev 14420)
+++ cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/mineosmodel_form.html 2009-03-26 03:18:07 UTC (rev 14463)
@@ -1,8 +1,8 @@
<h2><img src="{{root}}/images/prem.gif" width=32 height=32> Rename Mineos Model</h2>
-{% if form.has_errors %}
-<p><span class=error>Please correct the following error{{ form.error_dict|pluralize }}.</span>
+{% if form.errors %}
+<p><span class=error>Please correct the following error{{ form.errors|pluralize }}.</span>
{% endif %}
<form method="post" action="{{action}}">
Modified: cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/mineosmodel_upload.html
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/mineosmodel_upload.html 2009-03-23 15:19:28 UTC (rev 14420)
+++ cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/mineosmodel_upload.html 2009-03-26 03:18:07 UTC (rev 14463)
@@ -5,8 +5,8 @@
<input type="hidden" name="class" value="MineosModel">
<input type="hidden" name="action" value="upload">
- {% if form.has_errors %}
- <p><span class=error>Please correct the following error{{ form.error_dict|pluralize }}.</span>
+ {% if form.errors %}
+ <p><span class=error>Please correct the following error{{ form.errors|pluralize }}.</span>
{% endif %}
<div class=tab30ex>
Modified: cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/mineosparameters_form.html
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/mineosparameters_form.html 2009-03-23 15:19:28 UTC (rev 14420)
+++ cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/mineosparameters_form.html 2009-03-26 03:18:07 UTC (rev 14463)
@@ -10,8 +10,8 @@
<input type="hidden" name="action" value="new">
{% endif %}
- {% if form.has_errors %}
- <p><span class=error>Please correct the following error{{ form.error_dict|pluralize }}.</span>
+ {% if form.errors %}
+ <p><span class=error>Please correct the following error{{ form.errors|pluralize }}.</span>
{% endif %}
<div class=tab30ex>
Modified: cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/outputfile_form.html
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/outputfile_form.html 2009-03-23 15:19:28 UTC (rev 14420)
+++ cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/outputfile_form.html 2009-03-26 03:18:07 UTC (rev 14463)
@@ -7,8 +7,8 @@
<h1>Output File</h1>
- {% if form.has_errors %}
- <p>{{ form.error_dict }}
+ {% if form.errors %}
+ <p>{{ form.errors }}
{% endif %}
<form method="post" action="{{action}}">
Modified: cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/password_change_form.html
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/password_change_form.html 2009-03-23 15:19:28 UTC (rev 14420)
+++ cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/password_change_form.html 2009-03-26 03:18:07 UTC (rev 14463)
@@ -7,8 +7,8 @@
<h2>Profile → Change Password</h2>
-{% if form.has_errors %}
-<p><span class=error>Please correct the following error{{ form.error_dict|pluralize }}.</span>
+{% if form.errors %}
+<p><span class=error>Please correct the following error{{ form.errors|pluralize }}.</span>
{% endif %}
<form action="{{action}}" method="post">
Modified: cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/register.html
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/register.html 2009-03-23 15:19:28 UTC (rev 14420)
+++ cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/register.html 2009-03-26 03:18:07 UTC (rev 14463)
@@ -10,8 +10,8 @@
<p>If you've registered before, but have simply forgotten your username and/or password, try <a href="{{root}}/pwreset/">resetting your password</a>.
If you need help, <a href="mailto:portal at geodynamics.org">contact us</a>.
-{% if form.has_errors %}
-<p><span class=error>Please correct the following error{{ form.error_dict|pluralize }}.</span>
+{% if form.errors %}
+<p><span class=error>Please correct the following error{{ form.errors|pluralize }}.</span>
{% endif %}
<form method="post" action="{{action}}" enctype="multipart/form-data">
Modified: cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/run_form.html
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/run_form.html 2009-03-23 15:19:28 UTC (rev 14420)
+++ cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/run_form.html 2009-03-26 03:18:07 UTC (rev 14463)
@@ -10,8 +10,8 @@
<input type="hidden" name="action" value="new">
{% endif %}
- {% if form.has_errors %}
- <p><span class=error>Please correct the following error{{ form.error_dict|pluralize }}.</span>
+ {% if form.errors %}
+ <p><span class=error>Please correct the following error{{ form.errors|pluralize }}.</span>
{% endif %}
<div class=tab30ex>
Modified: cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/single_source_event_form.html
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/single_source_event_form.html 2009-03-23 15:19:28 UTC (rev 14420)
+++ cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/single_source_event_form.html 2009-03-26 03:18:07 UTC (rev 14463)
@@ -1,8 +1,8 @@
<h2>{% if object %}Edit{% else %}New{% endif %} Event</h2>
-{% if form.has_errors %}
-<p><span class=error>Please correct the following error{{ form.error_dict|pluralize }}.</span>
+{% if form.errors %}
+<p><span class=error>Please correct the following error{{ form.errors|pluralize }}.</span>
{% endif %}
<form method="post" action="{{action}}">
Modified: cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobemodel_detail.html
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobemodel_detail.html 2009-03-23 15:19:28 UTC (rev 14420)
+++ cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobemodel_detail.html 2009-03-26 03:18:07 UTC (rev 14463)
@@ -4,5 +4,5 @@
{{ object.description }}
<pre>
-{{ object.list }}
+{{ object.list|safe }}
</pre>
Modified: cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobemodel_form.html
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobemodel_form.html 2009-03-23 15:19:28 UTC (rev 14420)
+++ cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobemodel_form.html 2009-03-26 03:18:07 UTC (rev 14463)
@@ -1,8 +1,8 @@
<h2><img src="{{root}}/images/s20rts.gif" width=32 height=32> Rename Specfem 3D Globe Model</h2>
-{% if form.has_errors %}
-<p><span class=error>Please correct the following error{{ form.error_dict|pluralize }}.</span>
+{% if form.errors %}
+<p><span class=error>Please correct the following error{{ form.errors|pluralize }}.</span>
{% endif %}
<form method="post" action="{{action}}">
Modified: cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobemodel_link.html
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobemodel_link.html 2009-03-23 15:19:28 UTC (rev 14420)
+++ cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobemodel_link.html 2009-03-26 03:18:07 UTC (rev 14463)
@@ -1,8 +1,8 @@
<h2><img src="{{root}}/images/s20rts.gif" width=32 height=32> Link to Specfem 3D Globe Model</h2>
-{% if form.has_errors %}
-<p><span class=error>Please correct the following error{{ form.error_dict|pluralize }}.</span>
+{% if form.errors %}
+<p><span class=error>Please correct the following error{{ form.errors|pluralize }}.</span>
{% endif %}
<form method="post" action="{{action}}">
Modified: cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobemodel_upload.html
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobemodel_upload.html 2009-03-23 15:19:28 UTC (rev 14420)
+++ cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobemodel_upload.html 2009-03-26 03:18:07 UTC (rev 14463)
@@ -5,8 +5,8 @@
<input type="hidden" name="class" value="Specfem3DGlobeModel">
<input type="hidden" name="action" value="upload">
- {% if form.has_errors %}
- <p><span class=error>Please correct the following error{{ form.error_dict|pluralize }}.</span>
+ {% if form.errors %}
+ <p><span class=error>Please correct the following error{{ form.errors|pluralize }}.</span>
{% endif %}
<div class=tab30ex>
Modified: cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobeparameters_form.html
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobeparameters_form.html 2009-03-23 15:19:28 UTC (rev 14420)
+++ cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobeparameters_form.html 2009-03-26 03:18:07 UTC (rev 14463)
@@ -10,14 +10,14 @@
<input type="hidden" name="action" value="new">
{% endif %}
- {% if form.has_errors %}
- <p><span class=error>Please correct the following error{{ form.error_dict|pluralize }}.</span>
+ {% if form.errors %}
+ <p><span class=error>Please correct the following error{{ form.errors|pluralize }}.</span>
{% endif %}
{% if 0 %}
-{% if form.has_errors %}
+{% if form.errors %}
<dl class=error>
- {% for f in form.error_dict.iteritems %}
+ {% for f in form.errors.iteritems %}
<dt>{{ f.0 }}</dt>
<dd>
<ul class=error>
Modified: cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/stationlist_form.html
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/stationlist_form.html 2009-03-23 15:19:28 UTC (rev 14420)
+++ cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/stationlist_form.html 2009-03-26 03:18:07 UTC (rev 14463)
@@ -1,8 +1,8 @@
<h2><img src="{{root}}/images/stationlist.gif" width=32 height=32> Rename Station List</h2>
-{% if form.has_errors %}
-<p><span class=error>Please correct the following error{{ form.error_dict|pluralize }}.</span>
+{% if form.errors %}
+<p><span class=error>Please correct the following error{{ form.errors|pluralize }}.</span>
{% endif %}
<form method="post" action="{{action}}">
Modified: cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/stationlist_upload.html
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/stationlist_upload.html 2009-03-23 15:19:28 UTC (rev 14420)
+++ cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/stationlist_upload.html 2009-03-26 03:18:07 UTC (rev 14463)
@@ -5,8 +5,8 @@
<input type="hidden" name="class" value="StationList">
<input type="hidden" name="action" value="upload">
- {% if form.has_errors %}
- <p><span class=error>Please correct the following error{{ form.error_dict|pluralize }}.</span>
+ {% if form.errors %}
+ <p><span class=error>Please correct the following error{{ form.errors|pluralize }}.</span>
{% endif %}
<div class=tab30ex>
Modified: cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/userinfo_form.html
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/userinfo_form.html 2009-03-23 15:19:28 UTC (rev 14420)
+++ cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/SeismoWebPortal/userinfo_form.html 2009-03-26 03:18:07 UTC (rev 14463)
@@ -7,8 +7,8 @@
<h2>Profile → Edit Contact Information</h2>
-{% if form.has_errors %}
-<p><span class=error>Please correct the following error{{ form.error_dict|pluralize }}.</span>
+{% if form.errors %}
+<p><span class=error>Please correct the following error{{ form.errors|pluralize }}.</span>
{% endif %}
<form method="post" action="{{action}}">
Modified: cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/registration/login.html
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/templates/registration/login.html 2009-03-23 15:19:28 UTC (rev 14420)
+++ cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/registration/login.html 2009-03-26 03:18:07 UTC (rev 14463)
@@ -5,9 +5,9 @@
<h2>Login</h2>
-{% if form.has_errors %}
+{% if form.errors %}
<dl class=error>
- {% for f in form.error_dict.iteritems %}
+ {% for f in form.errors.iteritems %}
<dt>{{ f.0 }}</dt>
<dd>
<ul class=error>
Modified: cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/registration/pwreset.html
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/templates/registration/pwreset.html 2009-03-23 15:19:28 UTC (rev 14420)
+++ cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/templates/registration/pwreset.html 2009-03-26 03:18:07 UTC (rev 14463)
@@ -9,8 +9,8 @@
<form action="{{action}}" method="post">
- {% if form.has_errors %}
- <p><span class=error>Please correct the following error{{ form.error_dict|pluralize }}.</span>
+ {% if form.errors %}
+ <p><span class=error>Please correct the following error{{ form.errors|pluralize }}.</span>
{% endif %}
<div class=tab30ex>
Modified: cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/views.py
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/views.py 2009-03-23 15:19:28 UTC (rev 14420)
+++ cs/portal/junk/northridge-django-v1.0/SeismoWebPortal/views.py 2009-03-26 03:18:07 UTC (rev 14463)
@@ -2,7 +2,6 @@
from django import forms
from django.conf import settings
from django.contrib.auth import login, logout
-from django.core import validators
from django.core.exceptions import PermissionDenied
from django.http import HttpResponse, HttpResponseRedirect, Http404
from django.shortcuts import render_to_response, get_object_or_404
@@ -38,7 +37,7 @@
className = request.REQUEST.get('class')
if className is None:
t = loader.get_template('SeismoWebPortal/home.html')
- ret = t.render({'root': root, 'user': request.user})
+ ret = t.render(Context({'root': root, 'user': request.user}))
else:
@@ -193,24 +192,23 @@
root = rootURL(request, pathname)
if not request.session.test_cookie_worked():
return HttpResponseRedirect('%s/nocookie/' % root)
- manipulator = AuthenticationForm(request)
redirect_to = request.REQUEST.get(REDIRECT_FIELD_NAME, '')
- if request.POST:
- errors = manipulator.get_validation_errors(request.POST)
- if not errors:
+ if request.method == "POST":
+ form = AuthenticationForm(data=request.POST)
+ if form.is_valid():
# Light security check -- make sure redirect_to isn't garbage.
if not redirect_to or '://' in redirect_to or ' ' in redirect_to:
redirect_to = '/accounts/profile/'
from django.contrib.auth import login
- user = manipulator.get_user()
+ user = form.get_user()
login(request, user)
request.session.delete_test_cookie()
return HttpResponseRedirect(redirect_to)
else:
- errors = {}
+ form = AuthenticationForm(request)
request.session.set_test_cookie()
return render_to_response(template_name, {
- 'form': forms.FormWrapper(manipulator, request.POST, errors),
+ 'form': form,
REDIRECT_FIELD_NAME: redirect_to,
'site_name': Site.objects.get_current().name,
'action': request.path,
@@ -226,17 +224,16 @@
def password_reset(request, pathname):
from django.contrib.auth.forms import PasswordResetForm
root = rootURL(request, pathname)
- new_data, errors = {}, {}
- form = PasswordResetForm()
- if request.POST:
- new_data = request.POST.copy()
- errors = form.get_validation_errors(new_data)
- if not errors:
+ if request.method == "POST":
+ form = PasswordResetForm(request.POST)
+ if form.is_valid():
form.save(email_template_name='registration/pwreset_email.txt',
domain_override="the CIG Seismology Web Portal")
return HttpResponseRedirect('%sdone/' % request.path)
+ else:
+ form = PasswordResetForm()
return render_to_response('registration/pwreset.html', dict(
- form = forms.FormWrapper(form, new_data, errors),
+ form = form,
action = request.path,
root = root,
), context_instance=RequestContext(request))
@@ -642,7 +639,7 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def registration(request, pathname, inviteCode=None):
- from forms import RegistrationAddManipulator, RegistrationChangeManipulator
+ from forms import NewRegistrationForm
from management import createExamplesForUser
root = rootURL(request, pathname)
@@ -651,19 +648,16 @@
if isNewUser:
if not request.session.test_cookie_worked():
return HttpResponseRedirect('%s/nocookie/' % root)
- manipulator = RegistrationAddManipulator(request, root)
+ #manipulator = RegistrationAddManipulator(request, root)
template = 'SeismoWebPortal/register.html'
else:
- manipulator = RegistrationChangeManipulator(request.user)
+ #manipulator = RegistrationChangeManipulator(request.user)
template = 'SeismoWebPortal/userinfo_form.html'
- if request.method == 'POST':
- new_data = request.POST.copy()
- new_data.update(request.FILES)
- errors = manipulator.get_validation_errors(new_data)
- if not errors:
- manipulator.do_html2python(new_data)
- user, extraInfo, errors = manipulator.save(new_data, inviteCode)
+ if request.method == "POST":
+ form = NewRegistrationForm(request, root, data = request.POST, files = request.FILES)
+ if form.is_valid():
+ user, extraInfo, errors = form.save(inviteCode)
if not errors:
if isNewUser:
request.session.delete_test_cookie()
@@ -674,16 +668,11 @@
user.message_set.create(message="Your contact information has been saved.")
return HttpResponseRedirect("%s/" % root)
else:
- # Populate new_data with a 'flattened' version of the current data.
- new_data = manipulator.flatten_data()
- errors = {}
+ form = NewRegistrationForm(request, root)
if isNewUser:
request.session.set_test_cookie()
- # Populate the FormWrapper.
- form = forms.FormWrapper(manipulator, new_data, errors, edit_inline = True)
-
return render_to_response(template, dict(
form = form,
action = request.path,
More information about the CIG-COMMITS
mailing list