def favorite_action(request,vidnum): try: venue = Venue.objects.get(id=vidnum) old_favorite = get_or_none(Favorite,venue=venue, user=request.user) status = 0 if old_favorite: old_favorite.delete() status = 0 else: fav = Favorite() fav.user = request.user fav.venue = venue fav.save() status = 1 return HttpResponse(json.dumps({"is_fav": status}) ,content_type="applcation/json") except Exception, e: print e res = HttpResponse() res.status_code = 404 return res
def create_favorite(mediation=None, offer=None, user=None) -> Favorite: favorite = Favorite() favorite.user = user favorite.mediation = mediation favorite.offer = offer return favorite
def create_favorite(mediation: Mediation, offer: Offer, user: User) -> Favorite: favorite = Favorite() favorite.mediation = mediation favorite.offer = offer favorite.user = user return favorite