Skip to content

Commit

Permalink
registration_id no longer hard-coded in DeviceViewSetMixin
Browse files Browse the repository at this point in the history
`lookup_field` was declared in `DeviceViewSetMixin` and never used. Instead the create method referred to string literal instead of this field. No the field is used. You can inherit from `DeviceViewSetMixin`, redefined the `lookup_field` and use if with your views instead of having to rewrite the `create` method yourself
  • Loading branch information
DataGreed authored and Asif Saif Uddin committed Mar 10, 2020
1 parent eb83056 commit 0a78aa8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions push_notifications/api/rest_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ class DeviceViewSetMixin(object):
def create(self, request, *args, **kwargs):
serializer = None
is_update = False
if SETTINGS.get("UPDATE_ON_DUPLICATE_REG_ID") and "registration_id" in request.data:
if SETTINGS.get("UPDATE_ON_DUPLICATE_REG_ID") and self.lookup_field in request.data:
instance = self.queryset.model.objects.filter(
registration_id=request.data["registration_id"]
registration_id=request.data[self.lookup_field]
).first()
if instance:
serializer = self.get_serializer(instance, data=request.data)
Expand Down

0 comments on commit 0a78aa8

Please sign in to comment.