Skip to content

Instantly share code, notes, and snippets.

@acmisiti
Created April 17, 2015 19:08
Show Gist options
  • Save acmisiti/55295553f7b4866aac80 to your computer and use it in GitHub Desktop.
Save acmisiti/55295553f7b4866aac80 to your computer and use it in GitHub Desktop.
OfferingResource
def dehydrate(self, bundle):
""" additional attributes for offerings that need to be added to the JSON responses """
from apps.offerings.models import RoadShowEvent
from apps.offerings.models import Document
###################################
# ATTENTION TO WHO THIS MAY CONCERN
#
# THIS IS A HUGE HACK, but i am over-writing the offering.id to something
# random just for admin (important), because stefano wants to display all watchlists
# for the admin panel, but unfortuantely Backbone.Collection only allow unique model.id.
# The only way to display multipel offers in a backbone collection
# is to do this. this solves the problem,and since it is only for admin,
# which cannot update watchlists, it should be ok.
#
###################################
if hasattr(bundle.request,'user') and bundle.request.user.is_superuser and \
(bundle.request.path != '/offerings/primary' and \
bundle.request.path != '/docs/matured/deals' and \
bundle.request.path != '/docs/note-purchase-agreements' and \
bundle.request.path != '/offerings/secondary/all/outstanding'):
bundle.data["id"] = random.randint(1,99999)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment