예제 #1
0
 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
예제 #2
0
 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
예제 #3
0
    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
예제 #4
0
    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
예제 #5
0
    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
예제 #6
0
    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
예제 #7
0
 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)
예제 #8
0
 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)