From 6dc27b52ddd58218da5a06c88d29929dded1e95e Mon Sep 17 00:00:00 2001 From: Arvind S Raj Date: Tue, 20 Mar 2012 14:52:12 +0530 Subject: [PATCH 1/4] Revert "Merge pull request #9 from arvindsraj/master" This reverts commit 7fc65a1851a6ece50ddedfc9dd8edc47a675ce24, reversing changes made to f7881e1a003e0989ab7d271977a5c201ba58eafb. --- src/e_cidadania/apps/spaces/forms.py | 16 ---------------- src/e_cidadania/apps/spaces/models.py | 2 +- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/src/e_cidadania/apps/spaces/forms.py b/src/e_cidadania/apps/spaces/forms.py index a9caa06d..13c42055 100644 --- a/src/e_cidadania/apps/spaces/forms.py +++ b/src/e_cidadania/apps/spaces/forms.py @@ -24,20 +24,11 @@ from the data models. """ -import re - -from django import forms from django.forms import ModelForm from django.forms.models import modelformset_factory from e_cidadania.apps.spaces.models import Space, Document, Event, Entity -def is_valid_space_url(space_url): - if re.match('^[a-z0-9_]+$', space_url): - return True - else: - return False - class SpaceForm(ModelForm): """ @@ -51,13 +42,6 @@ class SpaceForm(ModelForm): class Meta: model = Space - def clean_url(self): - space_url = self.cleaned_data['url'] - if not is_valid_space_url(space_url): - raise forms.ValidationError("Invalid characters in the space URL.") - else: - return space_url - # Create a formset for entities. This formset can be attached to any other form # but will be usually attached to SpaceForm EntityFormSet = modelformset_factory(Entity, extra=3) diff --git a/src/e_cidadania/apps/spaces/models.py b/src/e_cidadania/apps/spaces/models.py index 70e32c8d..11ba39a2 100755 --- a/src/e_cidadania/apps/spaces/models.py +++ b/src/e_cidadania/apps/spaces/models.py @@ -49,7 +49,7 @@ class Space(models.Model): name = models.CharField(_('Name'), max_length=250, unique=True, help_text=_('Max: 250 characters')) url = models.CharField(_('URL'), max_length=100, unique=True, - help_text=_('Valid characters are lowercase, digits and underscores. This will be the \ + help_text=_('All lowercase. This will be the \ accesible URL')) description = models.TextField(_('Description'), default=_('Write here your description.')) From 8bd1982113263f00545a44ca77c18a3c275e8ec8 Mon Sep 17 00:00:00 2001 From: Arvind S Raj Date: Tue, 20 Mar 2012 15:00:23 +0530 Subject: [PATCH 2/4] Space URL chars must be lowercase, digits or underscore(using RegexValidator) --- src/e_cidadania/apps/spaces/models.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/e_cidadania/apps/spaces/models.py b/src/e_cidadania/apps/spaces/models.py index 11ba39a2..7b24d6b4 100755 --- a/src/e_cidadania/apps/spaces/models.py +++ b/src/e_cidadania/apps/spaces/models.py @@ -18,6 +18,7 @@ # You should have received a copy of the GNU General Public License # along with e-cidadania. If not, see . +from django.core.validators import RegexValidator from django.db import models from django.utils.translation import ugettext_lazy as _ from django.contrib.auth.models import User @@ -49,8 +50,12 @@ class Space(models.Model): name = models.CharField(_('Name'), max_length=250, unique=True, help_text=_('Max: 250 characters')) url = models.CharField(_('URL'), max_length=100, unique=True, - help_text=_('All lowercase. This will be the \ - accesible URL')) + validators=[RegexValidator( + regex='^[a-z0-9_]+$', + message='Invalid characters in the space URL.' + )], + help_text=_('Valid characters are lowercase, digits and \ + underscore. This will be the accesible URL')) description = models.TextField(_('Description'), default=_('Write here your description.')) date = models.DateTimeField(_('Date of creation'), auto_now_add=True) From ae9549b1f42567fe8c2f8b062c9bfbd191f869ba Mon Sep 17 00:00:00 2001 From: Arvind S Raj Date: Tue, 20 Mar 2012 15:58:28 +0530 Subject: [PATCH 3/4] Updated text to show that Description is publicly visible --- src/e_cidadania/apps/spaces/templates/spaces/space_add.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/e_cidadania/apps/spaces/templates/spaces/space_add.html b/src/e_cidadania/apps/spaces/templates/spaces/space_add.html index 97cd6169..ae8fdd88 100644 --- a/src/e_cidadania/apps/spaces/templates/spaces/space_add.html +++ b/src/e_cidadania/apps/spaces/templates/spaces/space_add.html @@ -204,7 +204,7 @@

{% trans "Entities participating" %}



{% trans "How to add new spaces" %}


  • {% trans "Space name" %}: {% trans "The name of the space. Have in mind that this name will be used as the URL of your space. We recommend to use all lowercase. (100 chars)" %}
  • -
  • {% trans "Description" %}: {% trans "An optional description for your space. It won't be showed to the users, but to the admins." %}
  • +
  • {% trans "Description" %}: {% trans "An optional description for your space. This is publicly visible to everyone." %}
  • {% trans "Logotype" %}: {% trans "An image of 75px height and 100px width." %}
  • {% trans "Banner" %}: {% trans "Another image. 75px height." %}
  • {% trans "Authorized groups" %}: {% trans "This will set up what users can access to your space." %}
  • From 9ee8be6a9ff61e75f0164c87629470105ae4c1e4 Mon Sep 17 00:00:00 2001 From: Arvind S Raj Date: Tue, 20 Mar 2012 16:10:31 +0530 Subject: [PATCH 4/4] Fixed error when user tries to access private space without permission --- src/e_cidadania/apps/spaces/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/e_cidadania/apps/spaces/views.py b/src/e_cidadania/apps/spaces/views.py index fc6832f8..a8abab34 100755 --- a/src/e_cidadania/apps/spaces/views.py +++ b/src/e_cidadania/apps/spaces/views.py @@ -189,7 +189,7 @@ def get_object(self): messages.warning(self.request, _("You're not registered to this space.")) self.template_name = 'not_allowed.html' - return space_object.none() + return space_object # Get extra context data def get_context_data(self, **kwargs):