Exemple #1
0
def create_mission_success(request):
    if request.method == 'POST' and request.POST['create_success']:
        view_helpers.set_mission_completed(
            request.user.get_profile(), 'tar')
        message = 'Step successfully completed'
    else:
        message = 'An error occured'
    return HttpResponse(message)
def extract_mission_upload(request):
    # Initialize data array and some default values.
    data = {}
    data['unpack_form'] = forms.ExtractUploadForm()
    data['unpack_success'] = False
    data['what_was_wrong_with_the_extracted_file'] = ''
    if request.method == 'POST':
        form = forms.ExtractUploadForm(request.POST, request.FILES)
        if form.is_valid():
            if form.cleaned_data['extracted_file'].read() == view_helpers.UntarMission.get_contents_we_want():
                data['unpack_success'] = True
                view_helpers.set_mission_completed(request.user.get_profile(), 'tar_extract')
            else:
                data['what_was_wrong_with_the_extracted_file'] = 'The uploaded file does not have the correct contents.'
        data['unpack_form'] = form
    return unpacking(request, data)
def upload(request):
    # Initialize data array and some default values.
    data = {}
    data['create_form'] = forms.UploadForm()
    data['create_success'] = False
    data['what_was_wrong_with_the_tarball'] = ''
    if request.method == 'POST':
        form = forms.UploadForm(request.POST, request.FILES)
        if form.is_valid():
            try:
                view_helpers.TarMission.check_tarfile(form.cleaned_data['tarfile'].read())
                data['create_success'] = True
                view_helpers.set_mission_completed(request.user.get_profile(), 'tar')
            except view_helpers.IncorrectTarFile, e:
                data['what_was_wrong_with_the_tarball'] = utf8(e)
        data['create_form'] = form
Exemple #4
0
def upload(request):
    # Initialize data array and some default values.
    data = {}
    data['create_form'] = forms.UploadForm()
    data['create_success'] = False
    data['what_was_wrong_with_the_tarball'] = ''
    if request.method == 'POST':
        form = forms.UploadForm(request.POST, request.FILES)
        if form.is_valid():
            try:
                view_helpers.TarMission.check_tarfile(
                    form.cleaned_data['tarfile'].read())
                data['create_success'] = True
                view_helpers.set_mission_completed(request.user.get_profile(),
                                                   'tar')
            except view_helpers.IncorrectTarFile, e:
                data['what_was_wrong_with_the_tarball'] = utf8(e)
        data['create_form'] = form
Exemple #5
0
def extract_mission_upload(request):
    # Initialize data array and some default values.
    data = {}
    data['unpack_form'] = forms.ExtractUploadForm()
    data['unpack_success'] = False
    data['what_was_wrong_with_the_extracted_file'] = ''
    if request.method == 'POST':
        form = forms.ExtractUploadForm(request.POST, request.FILES)
        if form.is_valid():
            if form.cleaned_data['extracted_file'].read(
            ) == view_helpers.UntarMission.get_contents_we_want():
                data['unpack_success'] = True
                view_helpers.set_mission_completed(request.user.get_profile(),
                                                   'tar_extract')
            else:
                data[
                    'what_was_wrong_with_the_extracted_file'] = 'The uploaded file does not have the correct contents.'
        data['unpack_form'] = form
    return unpacking(request, data)