Skip to content

Commit

Permalink
[#141] Merge branch 'develop' into feature/141_primary_locations
Browse files Browse the repository at this point in the history
  • Loading branch information
KasperBrandt committed Jun 26, 2014
2 parents b298b81 + aaeeda6 commit b06402c
Show file tree
Hide file tree
Showing 78 changed files with 1,892 additions and 873 deletions.
6 changes: 3 additions & 3 deletions akvo/api/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# See more details in the license.txt file located at the root folder of the Akvo RSR module.
# For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.

from django.contrib.auth.models import User
from django.contrib.auth import get_user_model
from django.contrib.contenttypes.models import ContentType

from tastypie.authentication import ApiKeyAuthentication
Expand Down Expand Up @@ -41,8 +41,8 @@ def is_authenticated(self, request, **kwargs):
return self._unauthorized()

try:
user = User.objects.get(username=username)
except (User.DoesNotExist, User.MultipleObjectsReturned):
user = get_user_model().objects.get(username=username)
except (get_user_model().DoesNotExist, get_user_model().MultipleObjectsReturned):
return self._unauthorized()

request.user = user
Expand Down
2 changes: 2 additions & 0 deletions akvo/api/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from .focus_area import FocusAreaResource
from .goal import GoalResource, IATIGoalResource
from .invoice import InvoiceResource
from .keyword import KeywordResource
from .link import LinkResource
from .location import (
IATIProjectLocationResource, OrganisationLocationResource, OrganisationMapLocationResource,
Expand Down Expand Up @@ -44,6 +45,7 @@
'IATIProjectLocationResource',
'IATIProjectResource',
'InvoiceResource',
'KeywordResource',
'LinkResource',
'OrganisationResource',
'OrganisationLocationResource',
Expand Down
18 changes: 18 additions & 0 deletions akvo/api/resources/keyword.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-

# Akvo RSR is covered by the GNU Affero General Public License.
# See more details in the license.txt file located at the root folder of the Akvo RSR module.
# For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.


from akvo.rsr.models import Keyword

from .resources import ConditionalFullResource


class KeywordResource(ConditionalFullResource):
class Meta:
allowed_methods = ['get']
queryset = Keyword.objects.all()
resource_name = 'keyword'
fields = ['id', 'label',]
6 changes: 4 additions & 2 deletions akvo/api/resources/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from akvo.api.serializers import IATISerializer

from akvo.rsr.models import (
Project, Benchmarkname, Category, Goal, Partnership, BudgetItem, ProjectLocation, Benchmark
Project, Benchmarkname, Category, Goal, Partnership, BudgetItem, ProjectLocation, Benchmark, Keyword
)
from akvo.utils import RSR_LIMITED_CHANGE

Expand Down Expand Up @@ -105,6 +105,7 @@ def obj_update(self, bundle, skip_errors=False, **kwargs):
ProjectLocation.objects.filter(location_target=bundle.obj).delete()
Partnership.objects.filter(project=bundle.obj).delete()
Benchmark.objects.filter(project=bundle.obj).delete()
Keyword.objects.filter(project=bundle.obj).delete()
bundle.obj.categories.clear()

self.authorized_update_detail(self.get_object_list(bundle.request), bundle)
Expand Down Expand Up @@ -239,6 +240,7 @@ class ProjectResource(ConditionalFullResource):
budget_items = ConditionalFullToManyField('akvo.api.resources.BudgetItemResource', 'budget_items')
categories = ConditionalFullToManyField('akvo.api.resources.CategoryResource', 'categories')
goals = ConditionalFullToManyField('akvo.api.resources.GoalResource', 'goals')
keywords = ConditionalFullToManyField('akvo.api.resources.KeywordResource', 'keywords')
invoices = ConditionalFullToManyField('akvo.api.resources.InvoiceResource', 'invoices')
links = ConditionalFullToManyField('akvo.api.resources.LinkResource', 'links')
locations = ConditionalFullToManyField('akvo.api.resources.ProjectLocationResource', 'locations')
Expand All @@ -249,7 +251,7 @@ class ProjectResource(ConditionalFullResource):

class Meta:
allowed_methods = ['get']
authentication = MultiAuthentication(ApiKeyAuthentication(), Authentication(),)
authentication = ConditionalApiKeyAuthentication(methods_requiring_key=['POST', 'PUT'])
queryset = Project.objects.all() #Note: this is modified in get_object_list()
resource_name = 'project'
include_absolute_url = True
Expand Down
4 changes: 2 additions & 2 deletions akvo/api/resources/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.


from django.contrib.auth.models import User
from django.contrib.auth import get_user_model

from tastypie.authentication import ApiKeyAuthentication
from tastypie.constants import ALL_WITH_RELATIONS, ALL
Expand All @@ -23,7 +23,7 @@ class UserResource(ConditionalFullResource):
class Meta:
authentication = ApiKeyAuthentication()
allowed_methods = ['get']
queryset = User.objects.filter(is_active=True)
queryset = get_user_model().objects.filter(is_active=True)
resource_name = 'user'
fields = ['username', 'first_name', 'last_name', 'last_login',]
filtering = dict(
Expand Down
42 changes: 0 additions & 42 deletions akvo/rest/serializers.py

This file was deleted.

55 changes: 55 additions & 0 deletions akvo/rest/serializers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# -*- coding: utf-8 -*-

# Akvo RSR is covered by the GNU Affero General Public License.
# See more details in the license.txt file located at the root folder of the Akvo RSR module.
# For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.

from .benchmark import BenchmarkSerializer
from .benchmark_name import BenchmarknameSerializer
from .budget_item import BudgetItemSerializer
from .budget_item_label import BudgetItemLabelSerializer
from .category import CategorySerializer
from .country import CountrySerializer
from .focus_area import FocusAreaSerializer
from .goal import GoalSerializer
from .internal_organisation_id import InternalOrganisationIDSerializer
from .invoice import InvoiceSerializer
from .link import LinkSerializer
from .organisation import OrganisationSerializer
from .organisation_location import OrganisationLocationSerializer
from .partner_site import PartnerSiteSerializer
from .partner_type import PartnerTypeSerializer
from .partnership import PartnershipSerializer
from .project import ProjectSerializer
from .project_comment import ProjectCommentSerializer
from .project_location import ProjectLocationSerializer
from .project_update import ProjectUpdateSerializer
from .publishing_status import PublishingStatusSerializer
from .user import UserSerializer
from .user_profile import UserProfileSerializer

__all__ = [
'BenchmarkSerializer',
'BenchmarknameSerializer',
'BudgetItemSerializer',
'BudgetItemLabelSerializer',
'CategorySerializer,'
'CountrySerializer',
'FocusAreaSerializer',
'GoalSerializer',
'InternalOrganisationIDSerializer',
'InvoiceSerializer',
'LinkSerializer',
'OrganisationSerializer',
'OrganisationLocationSerializer',
'PartnerSiteSerializer',
'PartnerTypeSerializer',
'PartnershipSerializer',
'ProjectSerializer',
'ProjectCommentSerializer',
'ProjectLocationSerializer',
'ProjectUpdateSerializer',
'PublishingStatusSerializer',
'UserSerializer,'
'UserProfileSerializer',
]
18 changes: 18 additions & 0 deletions akvo/rest/serializers/benchmark.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-

# Akvo RSR is covered by the GNU Affero General Public License.
# See more details in the license.txt file located at the root folder of the Akvo RSR module.
# For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.


from akvo.rsr.models import Benchmark

from .rsr_serializer import BaseRSRSerializer


class BenchmarkSerializer(BaseRSRSerializer):

class Meta:
model = Benchmark
fields = (
)
18 changes: 18 additions & 0 deletions akvo/rest/serializers/benchmark_name.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-

# Akvo RSR is covered by the GNU Affero General Public License.
# See more details in the license.txt file located at the root folder of the Akvo RSR module.
# For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.


from akvo.rsr.models import Benchmarkname

from .rsr_serializer import BaseRSRSerializer


class BenchmarknameSerializer(BaseRSRSerializer):

class Meta:
model = Benchmarkname
fields = (
)
18 changes: 18 additions & 0 deletions akvo/rest/serializers/budget_item.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-

# Akvo RSR is covered by the GNU Affero General Public License.
# See more details in the license.txt file located at the root folder of the Akvo RSR module.
# For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.


from akvo.rsr.models import BudgetItem

from .rsr_serializer import BaseRSRSerializer


class BudgetItemSerializer(BaseRSRSerializer):

class Meta:
model = BudgetItem
fields = (
)
18 changes: 18 additions & 0 deletions akvo/rest/serializers/budget_item_label.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-

# Akvo RSR is covered by the GNU Affero General Public License.
# See more details in the license.txt file located at the root folder of the Akvo RSR module.
# For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.


from akvo.rsr.models import BudgetItemLabel

from .rsr_serializer import BaseRSRSerializer


class BudgetItemLabelSerializer(BaseRSRSerializer):

class Meta:
model = BudgetItemLabel
fields = (
)
18 changes: 18 additions & 0 deletions akvo/rest/serializers/category.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-

# Akvo RSR is covered by the GNU Affero General Public License.
# See more details in the license.txt file located at the root folder of the Akvo RSR module.
# For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.


from akvo.rsr.models import Category

from .rsr_serializer import BaseRSRSerializer


class CategorySerializer(BaseRSRSerializer):

class Meta:
model = Category
fields = (
)
18 changes: 18 additions & 0 deletions akvo/rest/serializers/country.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-

# Akvo RSR is covered by the GNU Affero General Public License.
# See more details in the license.txt file located at the root folder of the Akvo RSR module.
# For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.


from akvo.rsr.models import Country

from .rsr_serializer import BaseRSRSerializer


class CountrySerializer(BaseRSRSerializer):

class Meta:
model = Country
fields = (
)
18 changes: 18 additions & 0 deletions akvo/rest/serializers/focus_area.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-

# Akvo RSR is covered by the GNU Affero General Public License.
# See more details in the license.txt file located at the root folder of the Akvo RSR module.
# For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.


from akvo.rsr.models import FocusArea

from .rsr_serializer import BaseRSRSerializer


class FocusAreaSerializer(BaseRSRSerializer):

class Meta:
model = FocusArea
fields = (
)
18 changes: 18 additions & 0 deletions akvo/rest/serializers/goal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-

# Akvo RSR is covered by the GNU Affero General Public License.
# See more details in the license.txt file located at the root folder of the Akvo RSR module.
# For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.


from akvo.rsr.models import Goal

from .rsr_serializer import BaseRSRSerializer


class GoalSerializer(BaseRSRSerializer):

class Meta:
model = Goal
fields = (
)
18 changes: 18 additions & 0 deletions akvo/rest/serializers/internal_organisation_id.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-

# Akvo RSR is covered by the GNU Affero General Public License.
# See more details in the license.txt file located at the root folder of the Akvo RSR module.
# For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.


from akvo.rsr.models import InternalOrganisationID

from .rsr_serializer import BaseRSRSerializer


class InternalOrganisationIDSerializer(BaseRSRSerializer):

class Meta:
model = InternalOrganisationID
fields = (
)
18 changes: 18 additions & 0 deletions akvo/rest/serializers/invoice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-

# Akvo RSR is covered by the GNU Affero General Public License.
# See more details in the license.txt file located at the root folder of the Akvo RSR module.
# For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.


from akvo.rsr.models import Invoice

from .rsr_serializer import BaseRSRSerializer


class InvoiceSerializer(BaseRSRSerializer):

class Meta:
model = Invoice
fields = (
)
Loading

0 comments on commit b06402c

Please sign in to comment.