Start with the archive upload functionality (sponsored by Scilab);

add a new view and plain form to upload an archive; rename the internal
URLs, handlers and templates from submit to create for single downloads
and also add a help section about the new format as well as a detailed
FAQ entry. Archive files get a bigger upload limit (default: 20MB).

Next up: archive uploading, validation and processing.
This commit is contained in:
Thomas Keller
2011-11-02 00:15:33 +01:00
parent 34fbf6ec5f
commit c71ed2cecb
11 changed files with 404 additions and 10 deletions

View File

@@ -224,11 +224,11 @@ class IDF_Views_Download
}
/**
* Submit a new file for download.
* Create a new file for download.
*/
public $submit_precond = array('IDF_Precondition::accessDownloads',
public $create_precond = array('IDF_Precondition::accessDownloads',
'IDF_Precondition::projectMemberOrOwner');
public function submit($request, $match)
public function create($request, $match)
{
$prj = $request->project;
$title = __('New Download');
@@ -250,7 +250,7 @@ class IDF_Views_Download
array('project' => $prj,
'user' => $request->user));
}
return Pluf_Shortcuts_RenderToResponse('idf/downloads/submit.html',
return Pluf_Shortcuts_RenderToResponse('idf/downloads/create.html',
array(
'auto_labels' => self::autoCompleteArrays($prj),
'page_title' => $title,
@@ -259,6 +259,39 @@ class IDF_Views_Download
$request);
}
/**
* Create new downloads from an uploaded archive.
*/
public $createFromArchive_precond = array('IDF_Precondition::accessDownloads',
'IDF_Precondition::projectMemberOrOwner');
public function createFromArchive($request, $match)
{
$prj = $request->project;
$title = __('New Downloads from Archive');
if ($request->method == 'POST') {
$form = new IDF_Form_UploadArchive(array_merge($request->POST, $request->FILES),
array('project' => $prj,
'user' => $request->user));
if ($form->isValid()) {
$upload = $form->save();
$request->user->setMessage(__('The archive has been uploaded and processed.'));
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Download::index',
array($prj->shortname));
return new Pluf_HTTP_Response_Redirect($url);
}
} else {
$form = new IDF_Form_UploadArchive(null,
array('project' => $prj,
'user' => $request->user));
}
return Pluf_Shortcuts_RenderToResponse('idf/downloads/createFromArchive.html',
array(
'page_title' => $title,
'form' => $form,
),
$request);
}
/**
* Create the autocomplete arrays for the little AJAX stuff.
*/