Skip to content

Commit

Permalink
Merge pull request #590 from akvo/feature/du586_modelforms_fields
Browse files Browse the repository at this point in the history
[#586] Update ModelForm fields for Django 1.6
  • Loading branch information
zzgvh committed May 27, 2014
2 parents 78dc6e2 + ad58b1e commit 557c55b
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 14 deletions.
1 change: 1 addition & 0 deletions akvo/api/resources/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
class IATIProjectModelForm(ModelForm):
class Meta:
model = Project
fields = "__all__"


class IATIProjectResource(ModelResource):
Expand Down
1 change: 1 addition & 0 deletions akvo/api/resources/project_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
class ProjectUpdateModelForm(ModelForm):
class Meta:
model = ProjectUpdate
fields = "__all__"


class ProjectUpdateResource(ConditionalFullResource):
Expand Down
9 changes: 0 additions & 9 deletions akvo/rsr/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,6 @@ class InternalOrganisationIDAdmin(admin.ModelAdmin):


class OrganisationAdminForm(forms.ModelForm):
class Meta:
model = get_model('rsr', 'organisation')

def clean_iati_org_id(self):
return self.cleaned_data['iati_org_id'] or None

Expand Down Expand Up @@ -507,9 +504,6 @@ def duplicates_in_list(seq):


class RSR_PartnershipInlineForm(forms.ModelForm):
class Meta:
model = get_model('rsr', 'Partnership')

def clean_partner_type(self):
partner_types = get_model('rsr', 'PartnerType').objects.all()
partner_types_dict = {partner_type.id: partner_type.label for partner_type in partner_types}
Expand Down Expand Up @@ -937,9 +931,6 @@ class UserProfileAdminForm(forms.ModelForm):
This form displays two extra fields that show if the user belongs to the groups
GROUP_RSR_PARTNER_ADMINS and/or GROUP_RSR_PARTNER_EDITORS.
"""
class Meta:
model = get_model('rsr', 'userprofile')

is_active = forms.BooleanField(required=False, label=_(u'account is active'),)
is_org_admin = forms.BooleanField(required=False, label=_(u'organisation administrator'),)
is_org_editor = forms.BooleanField(required=False, label=_(u'organisation project editor'),)
Expand Down
6 changes: 2 additions & 4 deletions akvo/rsr/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,8 @@ class ProjectUpdateForm(forms.ModelForm):

class Meta:
model = get_model('rsr', 'projectupdate')
exclude = ('created_at', 'project', 'user', 'last_modified_at')
fields = ('title', 'text', 'language', 'photo', 'photo_caption', 'photo_credit', 'video', 'video_caption',
'video_credit')

def clean_video(self):
data = self.cleaned_data['video']
Expand All @@ -393,9 +394,6 @@ def clean_video(self):


class PartnerSiteAdminForm(forms.ModelForm):
class Meta:
model = get_model('rsr', 'partnersite')

def clean_hostname(self):
hostname = slugify(self.cleaned_data['hostname'])
if hostname == 'www': # TODO: test for other reserved hostnames
Expand Down
2 changes: 1 addition & 1 deletion akvo/rsr/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ class CommentForm(ModelForm):

class Meta:
model = ProjectComment
exclude = ('time', 'project', 'user', )
fields = ('comment',)


@login_required()
Expand Down

0 comments on commit 557c55b

Please sign in to comment.