Skip to content

Commit

Permalink
Merge pull request #219 from Jerome-Celle/remove_order_line_in_base_p…
Browse files Browse the repository at this point in the history
…roduct

Remove order_lines information on BaseProduct serializer
  • Loading branch information
RignonNoel authored Oct 9, 2019
2 parents 5a1874b + 63c1a00 commit 8cc2665
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 22 deletions.
1 change: 0 additions & 1 deletion blitz_api/tests/tests_view_Users.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,6 @@ def test_list_users(self):
membership = {
'url': 'http://testserver/memberships/' + str(self.membership.id),
'id': self.membership.id,
'order_lines': [],
'name': 'basic_membership',
'available': True,
'available_on_product_types': [],
Expand Down
7 changes: 1 addition & 6 deletions store/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,7 @@ def validate(self, attrs):

class BaseProductSerializer(serializers.HyperlinkedModelSerializer):
id = serializers.ReadOnlyField()
order_lines = serializers.HyperlinkedRelatedField(
many=True,
read_only=True,
view_name='orderline-detail'
)

price = serializers.DecimalField(
max_digits=6,
decimal_places=2,
Expand Down Expand Up @@ -150,7 +146,6 @@ def to_representation(self, instance):
self.fields['options'] = BaseProductManagerSerializer(many=True)
data = super(BaseProductSerializer, self).to_representation(instance)
if not user.is_staff:
data.pop("order_lines")
data = remove_translation_fields(data)

return data
Expand Down
5 changes: 0 additions & 5 deletions store/tests/tests_viewset_Membership.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ def test_create(self):
'details': '3-Year student membership',
'duration': '1095 00:00:00',
'name': 'advanced_membership',
'order_lines': [],
'price': '125.00',
'academic_levels': ['http://testserver/academic_levels/' +
str(self.academic_level.id)],
Expand Down Expand Up @@ -249,7 +248,6 @@ def test_update(self):
'details': '1-Year student membership',
'duration': '365 00:00:00',
'name': 'basic_membership_updated',
'order_lines': [],
'price': '10.00',
'url': 'http://testserver/memberships/' + str(self.membership.id),
'id': self.membership.id,
Expand Down Expand Up @@ -383,7 +381,6 @@ def test_list_as_admin(self):
'details': '1-Year student membership',
'duration': '365 00:00:00',
'name': 'basic_membership',
'order_lines': [],
'price': '50.00',
'url': 'http://testserver/memberships/' +
str(self.membership.id),
Expand All @@ -398,7 +395,6 @@ def test_list_as_admin(self):
'details': 'todo',
'duration': '365 00:00:00',
'name': 'pending_membership',
'order_lines': [],
'price': '50.00',
'url': 'http://testserver/memberships/' +
str(self.membership_unavailable.id),
Expand Down Expand Up @@ -464,7 +460,6 @@ def test_read_as_admin(self):
'details': '1-Year student membership',
'duration': '365 00:00:00',
'name': 'basic_membership',
'order_lines': [],
'price': '50.00',
'url': 'http://testserver/memberships/' + str(self.membership.id),
'academic_levels': ['http://testserver/academic_levels/' +
Expand Down
10 changes: 0 additions & 10 deletions store/tests/tests_viewset_Package.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ def test_create(self):
f'http://testserver/memberships/{self.membership.id}'],
'available': True,
'name': 'basic_package',
'order_lines': [],
'price': '50.00',
'reservations': 10,
'available_on_product_types': [],
Expand Down Expand Up @@ -300,8 +299,6 @@ def test_update(self):
'exclusive_memberships': [],
'id': self.package.id,
'name': 'extreme_package_updated',
'order_lines': [
f'http://testserver/order_lines/{self.order_line.id}'],
'price': '1.00',
'reservations': 999,
'url': f'http://testserver/packages/{self.package.id}',
Expand Down Expand Up @@ -343,8 +340,6 @@ def test_update_partial(self):
'exclusive_memberships': [],
'id': self.package.id,
'name': 'extreme_package',
'order_lines': [
f'http://testserver/order_lines/{self.order_line.id}'],
'price': '99.00',
'reservations': 100,
'url': f'http://testserver/packages/{self.package.id}',
Expand Down Expand Up @@ -474,8 +469,6 @@ def test_list_as_admin(self):
'exclusive_memberships': [],
'id': self.package.id,
'name': 'extreme_package',
'order_lines': [
f'http://testserver/order_lines/{self.order_line.id}'],
'price': '400.00',
'reservations': 100,
'url': f'http://testserver/packages/{self.package.id}',
Expand All @@ -488,7 +481,6 @@ def test_list_as_admin(self):
'exclusive_memberships': [],
'id': self.package_unavailable.id,
'name': 'pending_package',
'order_lines': [],
'price': '400.00',
'reservations': 100,
'url':
Expand Down Expand Up @@ -553,8 +545,6 @@ def test_read_admin(self):
'exclusive_memberships': [],
'id': self.package.id,
'name': 'extreme_package',
'order_lines': [
f'http://testserver/order_lines/{self.order_line.id}'],
'price': '400.00',
'reservations': 100,
'url': f'http://testserver/packages/{self.package.id}',
Expand Down

0 comments on commit 8cc2665

Please sign in to comment.