Пример #1
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
Пример #2
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:
                controllers.TarMission.check_tarfile(
                    form.cleaned_data['tarfile'].read())
                data['create_success'] = True
                StepCompletion.objects.get_or_create(
                    person=request.user.get_profile(),
                    step=Step.objects.get(name='tar'))
            except controllers.IncorrectTarFile, e:
                data['what_was_wrong_with_the_tarball'] = str(e)
        data['create_form'] = form
Пример #3
0
def creating(request, passed_data={}):
    state = TarMissionPageState(request, passed_data)
    state.this_mission_page_short_name = 'Creating'
    data = state.as_dict_for_template_context()
    data['create_form'] = forms.UploadForm()
    return (request, 'missions/tar/creating.html', data)