Skip to content

Commit

Permalink
[#797] Merge branch 'feature/835_v3_my_details' into feature/797_v3_c…
Browse files Browse the repository at this point in the history
…hange_pw
  • Loading branch information
KasperBrandt committed Oct 24, 2014
2 parents 20e5a1a + 5a74f21 commit 31aaff5
Show file tree
Hide file tree
Showing 12 changed files with 2,170 additions and 370 deletions.
9 changes: 8 additions & 1 deletion akvo/rest/serializers/employment.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,21 @@

from akvo.rsr.models import Employment

from .country import CountrySerializer
from .organisation import OrganisationSerializer
from .rsr_serializer import BaseRSRSerializer
from .user import UserSerializer


class EmploymentSerializer(BaseRSRSerializer):

organisation_name = serializers.Field(source='organisation.name')
# These two can be deleted, but are still used somewhere
organisation_name = serializers.Field(source='organisation.long_name')
country_name = serializers.Field(source='country.name')

organisation_full = OrganisationSerializer(source='organisation', required=False, read_only=True)
user_full = UserSerializer(source='user', required=False, read_only=True)
country_full = CountrySerializer(source='country', required=False, read_only=True)

class Meta:
model = Employment
7 changes: 5 additions & 2 deletions akvo/rsr/models/employment.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@ def __unicode__(self):
return self.user.first_name, self.user.last_name, ":", self.organisation.name

def to_dict(self):
country = '' if not self.country else model_to_dict(self.country)

return dict(
id=self.pk,
organisation=model_to_dict(self.organisation, fields=['id', 'name', 'long_name',]),
user=model_to_dict(self.user, fields=['id', 'first_name', 'last_name', 'email',]),
organisation_full=model_to_dict(self.organisation, fields=['id', 'name', 'long_name',]),
user_full=model_to_dict(self.user, fields=['id', 'first_name', 'last_name', 'email',]),
is_approved=self.is_approved,
job_title=self.job_title,
country_full=country,
)
1 change: 1 addition & 0 deletions akvo/rsr/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ def employments_dict(self):
employments_array.append(employment_obj)

return dict(
id=self.pk,
email=self.email,
first_name=self.first_name,
last_name=self.last_name,
Expand Down
Loading

0 comments on commit 31aaff5

Please sign in to comment.