Changeset 51b384a


Ignore:
Timestamp:
Sep 10, 2012, 4:50:40 AM (13 years ago)
Author:
Alex Dehnert <adehnert@…>
Branches:
master, space-access, stable, stage
Children:
72a3d90
Parents:
71e71e3
git-author:
Alex Dehnert <adehnert@…> (09/10/12 04:50:40)
git-committer:
Alex Dehnert <adehnert@…> (09/10/12 04:50:40)
Message:

Validate constitution_url (ASA-#76)

Location:
asadb
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • asadb/groups/models.py

    rc632b1c r51b384a  
    1616import settings
    1717
     18import mit
     19
    1820# Create your models here.
    1921
     
    3335    group_funding = models.ForeignKey('GroupFunding', null=True, blank=True, db_index=True, )
    3436    website_url = models.URLField()
    35     constitution_url = models.CharField(max_length=200, blank=True)
     37    constitution_url = models.CharField(max_length=200, blank=True, validators=[mit.UrlOrAfsValidator])
    3638    meeting_times = models.TextField(blank=True)
    3739    advisor_name = models.CharField(max_length=100, blank=True)
  • asadb/groups/views.py

    r71e71e3 r51b384a  
    128128        for field in self.force_required:
    129129            self.fields[field].required = True
    130         self.fields['constitution_url'].help_text = mark_safe("Please put your current constitution URL, if you have one.<br>If your constitution is currently an AFS path, you can either use the corresponding web.mit.edu (e.g., http://web.mit.edu/locker/path/to/const.html) or stuff.mit.edu path, or just use http://asa.mit.edu/const/afs/your-afs-path.<br>If you don't currently know where your constitution is, put http://mit.edu/asa/start/constitution-req.html.<br>(In either of these last two cases, we'll get in touch with you later about putting something better in.)")
     130        self.fields['constitution_url'].help_text = mark_safe("""Please put your current constitution URL or AFS path.<br>If you don't currently know where your constitution is, put "http://mit.edu/asa/start/constitution-req.html" and draft a constitution soon.""")
    131131
    132132    exec_only_fields = [
  • asadb/mit/__init__.py

    r7045dd8 r51b384a  
    1010from django.contrib import auth
    1111from django.core.exceptions import ObjectDoesNotExist
     12from django.core.validators import URLValidator, ValidationError
     13
    1214import settings
    1315
     
    1820    )
    1921    proc.communicate(msg)
     22
     23def UrlOrAfsValidator(value):
     24    if value.startswith('/mit/') or value.startswith('/afs/'):
     25        return
     26    else:
     27        try:
     28            URLValidator()(value)
     29        except ValidationError:
     30            raise ValidationError('Provide a valid URL or AFS path')
    2031
    2132class ScriptsRemoteUserMiddleware(RemoteUserMiddleware):
Note: See TracChangeset for help on using the changeset viewer.