def get_donations(cls, owner_username): from sb_donations.neo_models import Donation query = 'MATCH (c:Quest {owner_username:"******"})-[:EMBARKS_ON]->' \ '(mission:Mission)<-' \ '[:CONTRIBUTED_TO]-(d:Donation) RETURN d' % owner_username res, _ = db.cypher_query(query) return [Donation.inflate(donation[0]) for donation in res]
def donations(self, request): query = 'MATCH (a:Pleb {username:"******"})-[:DONATIONS_GIVEN]->' \ '(d:Donation)-[:CONTRIBUTED_TO]->(:Mission) ' \ 'RETURN d ORDER BY d.created DESC' % \ request.user.username res, _ = db.cypher_query(query) queryset = [Donation.inflate(row[0]) for row in res] html = self.request.query_params.get('html', 'false') page = self.paginate_queryset(queryset) serializer = self.get_serializer(page, many=True, context={'request': request}) if html == 'true': html_array = [] for item in serializer.data: context = RequestContext(request, item) html_array.append( render_to_string("settings/donation_block.html", context)) return self.get_paginated_response(html_array) return self.get_paginated_response(serializer.data)
def get_donations(cls, object_uuid): from sb_donations.neo_models import Donation query = 'MATCH (c:Mission {object_uuid:"%s"})<-' \ '[:CONTRIBUTED_TO]-(d:Donation) RETURN d' % object_uuid res, _ = db.cypher_query(query) return [Donation.inflate(donation[0]) for donation in res]