def verifyEventPayment(request, attendee_id):
    authMember = isAuthenticated(request)
    if not authMember:
        notlogged()
    else:
        attendee = EventAttendees.objects.get(id=attendee_id)
        if authMember.is_board_member:
            attendee.has_paid = True
            attendee.save()
        return JSONResponse({"member": "Payment successful."}, status=200)
def verifyMember(request, mem_id):
    authMember = isAuthenticated(request)
    if not authMember:
        notlogged()
    else:
        mem = Member.objects.get(id=mem_id)
        if authMember.is_board_member:
            mem.is_verified = True
            mem.save()
        return JSONResponse({"member": "Update successful."}, status=200)
Exemple #3
0
def memberHandler(request):
    if request.method == 'PUT':
        return addMember(request)

    authMember = isAuthenticated(request)
    if not authMember:
        notlogged()
    else:
        if request.method == 'POST':
            return updateMember(request, authMember)
        if request.method == 'DELETE':
            authMember.delete()
            return JSONResponse(getMembers(), status=200)
def upload(request):
    authMember = isAuthenticated(request)
    if not authMember:
        notlogged()
    else:
        files = request.FILES.getlist("files")
        if len(files) > 0:
                for file in files:
                    acc = AccountFile(url=file)
                    acc.save()
                    updateTNAAccountTable(acc.url)
                    default_storage.delete(MEDIA_ROOT + '/' + str(acc.url))
                return JSONResponse({"account": getAccounts()}, status=200)

        else:
            return JSONResponse({'msg': "No files found"}, status=200)
Exemple #5
0
def uploadProfilePic(request):
    authMember = isAuthenticated(request)
    if not authMember:
        notlogged()
    else:
        if request.method == 'POST':
            if len(request.FILES) > 0:
                for i in request.FILES:
                    file = request.FILES[i]
                    try:
                        pic = ProfilePictures.objects.get(owner=authMember)
                        default_storage.delete(MEDIA_ROOT + '/' + str(pic.url))
                        pic.url = file
                        pic.save()
                    except:
                        ProfilePictures(url=file, owner=authMember).save()

        return JSONResponse(getCleanObject(json.loads(serialize('json', [authMember]))), status=200)
Exemple #6
0
def galleryHandler(request):
    authMember = isAuthenticated(request)
    if not authMember:
        notlogged()
    else:
        if request.method == 'PUT':
            return uploadgallery(request, authMember)
        elif request.method == 'POST':
            res = JSONParser().parse(request)
            if res['type'] == 'gallery':
                return updategallery(request, res['gallery_id'])
            if res['type'] == 'cover_photo':
                return updatecover_photo(request, res['gallery_id'],
                                         res['pic_id'])
        elif request.method == 'DELETE':
            res = JSONParser().parse(request)
            if res['type'] == 'gallery':
                return deletegallery(request, res['gallery_id'])
            elif res['type'] == 'picture':
                return deletegallery(request, res['gallery_id'], res['pic_id'])
def getAllData(request):
    data = {
        'member': getMembers(),
        'infos': getInfos(),
        'events': getEvents(),
        'gallery': getGalleries(),
        'eventAttendees': getEventAttendees()
    }
    authMember = isAuthenticated(request)
    if authMember:
        data['accounts'] = getAccounts()
        data['user'] = getCleanObject(
            json.loads(serialize('json', [authMember])))[0]
        pics = json.loads(
            serialize('json',
                      ProfilePictures.objects.filter(owner=authMember.id)))
        data['user']['profilepicture'] = ''
        if len(pics) > 0:
            data['user']['profilepicture'] = pics[0]['fields']['url']
    return JSONResponse(data, status=200)
def eventsHandler(request):
    authMember = isAuthenticated(request)
    if not authMember:
        notlogged()
    else:
        if request.method == 'PUT':
            return addEvent(request, authMember)
        elif request.method == 'POST':
            return updateEvent(request)

        elif request.method == 'DELETE':
            res = JSONParser().parse(request)
            try:
                evt = Events.objects.get(id=res['id'], owner=authMember)
                evt.delete()
                return JSONResponse({'events': getEvents()}, status=200)
            except:
                return JSONResponse(
                    {"message": "Your are not the owner of "
                     "this event."},
                    status=400)