def handle_uploaded_file(self, upload): upload_ext = os.path.splitext(upload.name)[1] generated_filename = unique_name(upload.name) + upload_ext upload_filename = settings.UPLOAD_PATH + generated_filename out = open(upload_filename, 'wb+') for chunk in upload.chunks(): out.write(chunk) out.close() return generated_filename
def handle_uploaded_file(self, upload, request): upload_ext = os.path.splitext(upload.name)[1] generated_filename = unique_name(upload.name) + upload_ext upload_filename = settings.UPLOAD_PATH + generated_filename out = open(upload_filename, 'wb+') for chunk in upload.chunks(): out.write(chunk) out.close() self.create_thumbnail(generated_filename) self.create_display_image(generated_filename) return generated_filename
def start_booking_session(self): response = reply_object() event_object = self.save() order_key = unique_name(self.request.META["REMOTE_ADDR"]) event_booking = EventBooking.objects.create( event=event_object, order_key=order_key, status=settings.EVENT_BOOKING_STATUS["PENDING"] ) event_booking.save() response["code"] = settings.APP_CODE["REDIRECT"] response["redirect_url"] = "/payment" return response
def start_booking_session(self): response = reply_object() event_object = self.save() order_key = unique_name(self.request.META['REMOTE_ADDR']) event_booking = EventBooking.objects.create( event=event_object, order_key=order_key, status=settings.EVENT_BOOKING_STATUS["PENDING"]) event_booking.save() response["code"] = settings.APP_CODE["REDIRECT"] response["redirect_url"] = "/payment" return response
def vote_album(self): response = reply_object() album = Album.objects.get(pk=self.cleaned_data["object_id"]) if "user_key" not in self.request.session: self.request.session["user_key"] = unique_name(self.request.META["REMOTE_ADDR"]) album_vote, created = AlbumVote.objects.get_or_create( key=self.request.session["user_key"], album=album, vote=self.cleaned_data["vote"] ) response["code"] = settings.APP_CODE["CALLBACK"] response[settings.APP_CODE["SERVER MESSAGE"]] = "Vote submitted" return response
def vote_album(self): response = reply_object() album = Album.objects.get(pk=self.cleaned_data["object_id"]) if "user_key" not in self.request.session: self.request.session["user_key"] = unique_name( self.request.META["REMOTE_ADDR"]) album_vote, created = AlbumVote.objects.get_or_create( key=self.request.session["user_key"], album=album, vote=self.cleaned_data["vote"]) response["code"] = settings.APP_CODE["CALLBACK"] response[settings.APP_CODE["SERVER MESSAGE"]] = "Vote submitted" return response
def test_vote(self): album = Album.objects.all()[0] album_vote, created = AlbumVote.objects.get_or_create( key=unique_name("test"), album=album, vote=-1)