Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

...
  • 16 commits
  • 9 files changed
  • 0 commit comments
  • 5 contributors
Commits on Mar 20, 2012
Arvind dnivra Revert "Merge pull request #9 from arvindsraj/master"
This reverts commit 7fc65a1, reversing
changes made to f7881e1.
6dc27b5
Arvind dnivra Space URL chars must be lowercase, digits or underscore(using RegexVa…
…lidator)
8bd1982
Arvind dnivra Updated text to show that Description is publicly visible ae9549b
Arvind dnivra Fixed error when user tries to access private space without permission 9ee8be6
Bithin Alangot bithinalangot Corrected invalid url in userprofile overview template 9928a57
Oscar Carballal oscarcp Merge pull request #13 from arvindsraj/master
Restricted chars in space URLs and updated the description text
4e422c5
Oscar Carballal oscarcp Merge pull request #14 from bithin/master
Corrected invalid url in userprofile overview template
84fccca
Oscar Carballal oscarcp Merge pull request #12 from gurbinder533/master
Patch for a small problem on upvote botton for support
457f4bb
Arvind dnivra Fixed error on uploading a file without extension 12692a8
Oscar Carballal oscarcp Merge pull request #15 from arvindsraj/master
Fixed error on uploading files without extensions
f332a5d
Oscar Carballal oscarcp Merge pull request #16 from gurbinder533/master
Profile image uploading and cropping is working fine now .
ab5868c
Oscar Carballal oscarcp Fixed STATIC_URL referencing in crop avatar function 46a322d
Commits on Mar 21, 2012
Oscar Carballal oscarcp EditPost returned space name instead of space URL f5e2321
Commits on Mar 22, 2012
Bithin Alangot bithinalangot Patch for Ticket #159 9e7afa1
Oscar Carballal oscarcp Merge pull request #18 from bithin/master
Validation in add space form corrected.
e080c00
Gurbinder Gill solving ticket #156, now logged in user can not login or register N …
…times
b0e3b3d
2  src/e_cidadania/apps/news/views.py
View
@@ -103,7 +103,7 @@ class EditPost(UpdateView):
def get_success_url(self):
self.space = get_object_or_404(Space, url=self.kwargs['space_name'])
- return '/spaces/' + self.space.name
+ return '/spaces/' + self.space.url
def get_object(self):
cur_post = get_object_or_404(Post, pk=self.kwargs['post_id'])
34 src/e_cidadania/apps/spaces/forms.py
View
@@ -24,20 +24,11 @@
from the data models.
"""
-import re
-
-from django import forms
-from django.forms import ModelForm
+from django.forms import ModelForm, ValidationError
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,12 +42,23 @@ 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
+ def clean_logo(self):
+ valid_image_extensions = ['jpg', 'jpeg', 'png', 'gif']
+ logo_file = self.cleaned_data['logo']
+ for extension in valid_image_extensions:
+ if logo_file.name.endswith(''.join(['.', extension])):
+ return logo_file
+
+ raise ValidationError("Invalid file extension")
+
+ def clean_banner(self):
+ valid_image_extensions = ['jpg', 'jpeg', 'png', 'gif']
+ banner_file = self.cleaned_data['banner']
+ for extension in valid_image_extensions:
+ if banner_file.name.endswith(''.join(['.', extension])):
+ return banner_file
+
+ raise ValidationError("Invalid file extension")
# Create a formset for entities. This formset can be attached to any other form
# but will be usually attached to SpaceForm
15 src/e_cidadania/apps/spaces/models.py
View
@@ -18,6 +18,7 @@
# You should have received a copy of the GNU General Public License
# along with e-cidadania. If not, see <http://www.gnu.org/licenses/>.
+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,16 +50,22 @@ 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 \
- 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)
author = models.ForeignKey(User, blank=True, null=True,
verbose_name=_('Space creator'))
- logo = StdImageField(upload_to='spaces/logos', size=(100, 75, False))
- banner = StdImageField(upload_to='spaces/banners', size=(500, 75, False))
+ logo = StdImageField(upload_to='spaces/logos', size=(100, 75, False),
+ help_text = _('Valid extensions are jpg, jpeg, png and gif'))
+ banner = StdImageField(upload_to='spaces/banners', size=(500, 75, False),
+ help_text = _('Valid extensions are jpg, jpeg, png and gif'))
# logo = models.ImageField(upload_to='spaces/logos',
# verbose_name=_('Logotype'),
# help_text=_('100x75 pixels'))
46 src/e_cidadania/apps/spaces/templates/spaces/space_add.html
View
@@ -161,37 +161,53 @@
{% for entity in entityformset %}
{{ entity.id }}
- <div class="clearfix">
- {{ entity.errors }}
+ <div class="clearfix" {% if entity.name.errors %}error {% endif %}>
<label for="prependedInput">{{ entity.name.label }}</label>
<div class="input">
{{ entity.name }}
- <span class="help-inline">{{ entity.name.help_text }}</span>
+ <span class="help-inline">
+ {% if entity.name.errors %}
+ {% for error in entity.name.errors %}
+ {{ error|escape}}
+ {% endfor %}
+ {% else %}
+ {{ entity.name.help_text }}
+ {% endif %}
+ </span>
</div>
</div>
- <div class="clearfix">
- {{ entity.errors }}
+ <div class="clearfix" {% if entity.website.errors %}error{% endif %}>
<label for="prependedInput">{{ entity.website.label }}</label>
<div class="input">
{{ entity.website }}
- <span class="help-inline">{{ entity.website.help_text }}</span>
+ <span class="help-inline">
+ {% if entity.website.errors %}
+ {% for error in entity.website.errors %}
+ {{ error|escape }}
+ {% endfor %}
+ {% else %}
+ {{ entity.website.help_text }}
+ {% endif %}
+ </span>
</div>
</div>
- <div class="clearfix">
- {{ entity.errors }}
+ <div class="clearfix" {%if entity.logo.errors %}error{% endif %}>
<label for="prependedInput">{{ entity.logo.label }}</label>
<div class="input">
{{ entity.logo }}
- <span class="help-inline">{{ entity.logo.help_text }}</span>
+ <span class="help-inline">
+ {% if entity.logo.errors %}
+ {% for error in entity.logo.errors %}
+ {{ error|escape }}
+ {% endfor %}
+ {% else %}
+ {{ entity.logo.help_text }}
+ {% endif %}
+ </span>
</div>
</div>
-
- <div class="clearfix">
- <label for="prependedInput"><hr /></label>
- </div>
-
{% endfor %}
<hr />
@@ -204,7 +220,7 @@
<h4>{% trans "How to add new spaces" %}</h4><br/>
<ul class="instructions">
<li><strong>{% trans "Space name" %}</strong>: {% 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)" %}</li>
- <li><strong>{% trans "Description" %}</strong>: {% trans "An optional description for your space. It won't be showed to the users, but to the admins." %}</li>
+ <li><strong>{% trans "Description" %}</strong>: {% trans "An optional description for your space. This is publicly visible to everyone." %}</li>
<li><strong>{% trans "Logotype" %}</strong>: {% trans "An image of 75px height and 100px width." %}</li>
<li><strong>{% trans "Banner" %}</strong>: {% trans "Another image. 75px height." %}</li>
<li><strong>{% trans "Authorized groups" %}</strong>: {% trans "This will set up what users can access to your space." %}</li>
2  src/e_cidadania/apps/spaces/views.py
View
@@ -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):
8 src/e_cidadania/apps/userprofile/templates/userprofile/account/login.html
View
@@ -7,6 +7,10 @@
<div class="row" style="margin-top:100px;margin-bottom:100px;">
<div class="span3 offset3">
+ {% if user.is_authenticated %}
+ <p> You are already logged in as <strong>{{user.username}}</strong> </p>
+ {% else %}
+
<form action="{% if next %}?next={{ next }}{% endif %}" method="post" accept-charset="utf-8" class="form-stacked">{% csrf_token %}
<fieldset>
<legend>{% trans "User login" %}</legend>
@@ -36,8 +40,10 @@
</fieldset><br />
<p><input type="submit" class="btn" value="{% trans 'Login' %}" /></p>
- </form>
+ </form>
+ {% endif %}
</div>
+
<div class="span4 offset2">
<h4>{% trans "Helpful links" %}</h4>
<a href="{% url 'password_reset' %}">{% trans "Recover your password" %}</a><br />
4 src/e_cidadania/apps/userprofile/templates/userprofile/account/registration.html
View
@@ -8,6 +8,9 @@
<div class="row">
<div class="span12">
+ {% if user.is_authenticated %}
+ <p> You are already logged in as <strong>{{user.username}}</strong> </p>
+ {% else %}
<form action="" method="post" accept-charset="utf-8">
{% csrf_token %}
<h4>{% trans "User registration" %}</h4>
@@ -84,6 +87,7 @@
<p><input type="submit" value="{% trans 'Register' %}" class="btn btn-large" /></p>
</form>
+ {% endif %}
</div>
</div>
5 src/e_cidadania/apps/userprofile/templates/userprofile/avatar/crop.html
View
@@ -7,9 +7,8 @@
{% block extrajs %}
<!--<script type="text/javascript" src="{{ MEDIA_URL }}js/jquery.imgareaselect-0.4.2.min.js"></script>-->
<!------Adding new image select js and css files ---------->
-<link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}css/imgareaselect-default.css" />
-<script type="text/javascript" src="{{ MEDIA_URL }}js/jquery.min.js"></script>
-<script type="text/javascript" src="{{ MEDIA_URL }}js/jquery.imgareaselect.pack.js"></script>
+<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/imgareaselect-default.css" />
+<script type="text/javascript" src="{{ STATIC_URL }}js/jquery.imgareaselect.pack.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#cropimage').imgAreaSelect({
2  src/e_cidadania/apps/userprofile/templates/userprofile/profile/overview.html
View
@@ -136,7 +136,7 @@
</div>
<!-- Here goes the voting button -->
<div id="proposal">
- <div class="title" style="font-size: 1.5em;"><a href="/spaces/{{ p.belongs_to }}/proposal/view/{{ p.id }}/">{{ p.title }}</a></div>
+ <div class="title" style="font-size: 1.5em;"><a href="/spaces/{{ p.author }}/proposal/{{ p.id }}/">{{ p.title }}</a></div>
<div class="creator">{{ p.pub_date|date:"j/m/Y G:i" }}</div>
</div>
{% comment %}

No commit comments for this range

Something went wrong with that request. Please try again.