Fixed issue 6, ability to remove an uploaded file.
This commit is contained in:
parent
bd0209a28e
commit
59a81279ff
@ -122,6 +122,41 @@ class IDF_Views_Download
|
|||||||
$request);
|
$request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a file.
|
||||||
|
*/
|
||||||
|
public $delete_precond = array('IDF_Precondition::accessDownloads',
|
||||||
|
'IDF_Precondition::projectMemberOrOwner');
|
||||||
|
public function delete($request, $match)
|
||||||
|
{
|
||||||
|
$prj = $request->project;
|
||||||
|
$upload = Pluf_Shortcuts_GetObjectOr404('IDF_Upload', $match[2]);
|
||||||
|
$prj->inOr404($upload);
|
||||||
|
$title = sprintf(__('Delete Download %s'), $upload->summary);
|
||||||
|
$form = false;
|
||||||
|
$ptags = self::getDownloadTags($prj);
|
||||||
|
$dtag = array_pop($ptags); // The last tag is the deprecated tag.
|
||||||
|
$tags = $upload->get_tags_list();
|
||||||
|
$deprecated = Pluf_Model_InArray($dtag, $tags);
|
||||||
|
if ($request->method == 'POST') {
|
||||||
|
$fname = $upload->file;
|
||||||
|
@unlink(Pluf::f('upload_path').'/'.$prj->shortname.'/files/'.$fname);
|
||||||
|
$upload->delete();
|
||||||
|
$request->user->setMessage(__('The file has been deleted.'));
|
||||||
|
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Download::index',
|
||||||
|
array($prj->shortname));
|
||||||
|
return new Pluf_HTTP_Response_Redirect($url);
|
||||||
|
}
|
||||||
|
return Pluf_Shortcuts_RenderToResponse('downloads/delete.html',
|
||||||
|
array(
|
||||||
|
'file' => $upload,
|
||||||
|
'deprecated' => $deprecated,
|
||||||
|
'tags' => $tags,
|
||||||
|
'page_title' => $title,
|
||||||
|
),
|
||||||
|
$request);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Download a file.
|
* Download a file.
|
||||||
*/
|
*/
|
||||||
|
@ -179,6 +179,12 @@ $ctl[] = array('regex' => '#^/p/(\w+)/downloads/create/$#',
|
|||||||
'model' => 'IDF_Views_Download',
|
'model' => 'IDF_Views_Download',
|
||||||
'method' => 'submit');
|
'method' => 'submit');
|
||||||
|
|
||||||
|
$ctl[] = array('regex' => '#^/p/(\w+)/downloads/(\d+)/delete/$#',
|
||||||
|
'base' => $base,
|
||||||
|
'priority' => 4,
|
||||||
|
'model' => 'IDF_Views_Download',
|
||||||
|
'method' => 'delete');
|
||||||
|
|
||||||
|
|
||||||
// ---------- ADMIN --------------------------------------
|
// ---------- ADMIN --------------------------------------
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
40
src/IDF/templates/downloads/delete.html
Normal file
40
src/IDF/templates/downloads/delete.html
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
{extends "downloads/base.html"}
|
||||||
|
{block docclass}yui-t3{assign $inDownloads=true}{/block}
|
||||||
|
{block body}
|
||||||
|
|
||||||
|
<div class="download-file">
|
||||||
|
<a href="{url 'IDF_Views_Download::download', array($project.shortname, $file.id)}">{$file}</a> - {$file.filesize|size}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p>{blocktrans}<strong>Attention!</strong> If you want to delete a specific version of your software, maybe, someone is depending on this specific version to run his systems. Are you sure, you will not affect anybody when removing this file?{/blocktrans}</p>
|
||||||
|
|
||||||
|
{if !$deprecated}{aurl 'url', 'IDF_Views_Download::view', array($project.shortname, $file.id)}
|
||||||
|
<p>{blocktrans}Instead of deleting the file, you could <a href="{$url}">mark it as deprecated</a>.{/blocktrans}</p>{/if}
|
||||||
|
|
||||||
|
<form method="post" action=".">
|
||||||
|
<table class="form" summary="">
|
||||||
|
<tr>
|
||||||
|
<td> </td>
|
||||||
|
<td><input type="submit" value="{trans 'Delete File'}" name="submit" /> | <a href="{url 'IDF_Views_Download::index', array($project.shortname)}">{trans 'Cancel'}</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{/block}
|
||||||
|
|
||||||
|
{block context}
|
||||||
|
{assign $submitter = $file.get_submitter()}
|
||||||
|
<p><strong>{trans 'Uploaded:'}</strong> <span class="nobrk">{$file.creation_dtime|dateago}</span> <span class="nobrk">{blocktrans}by {$submitter}{/blocktrans}</span></p>
|
||||||
|
{if $file.modif_dtime != $file.creation_dtime}<p>
|
||||||
|
<strong>{trans 'Updated:'}</strong> <span class="nobrk">{$file.modif_dtime|dateago}</span></p>{/if}
|
||||||
|
<p>
|
||||||
|
<strong>{trans 'Downloads:'}</strong> <span class="nobrk">{$file.downloads}</span></p>
|
||||||
|
{if $tags.count()}
|
||||||
|
<p>
|
||||||
|
<strong>{trans 'Labels:'}</strong><br />
|
||||||
|
{foreach $tags as $tag}{aurl 'url', 'IDF_Views_Download::listLabel', array($project.shortname, $tag.id)}
|
||||||
|
<span class="label"><a href="{$url}" class="label"><strong>{$tag.class}:</strong>{$tag.name}</a></span><br />
|
||||||
|
{/foreach}
|
||||||
|
</p>{/if}
|
||||||
|
{/block}
|
@ -38,8 +38,8 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td> </td>
|
<td> </td>{aurl 'url', 'IDF_Views_Download::delete', array($project.shortname, $file.id)}
|
||||||
<td><input type="submit" value="{trans 'Update File'}" name="submit" /> | <a href="{url 'IDF_Views_Download::index', array($project.shortname)}">{trans 'Cancel'}</a>
|
<td><input type="submit" value="{trans 'Update File'}" name="submit" /> | <a href="{url 'IDF_Views_Download::index', array($project.shortname)}">{trans 'Cancel'}</a> <span class="dellink"><a href="{$url}" title="{trans 'Remove this file'}"><img src="{media '/idf/img/trash.png'}" style="vertical-align: text-bottom;" alt="{trans 'Trash'}" /></a> <a href="{$url}" title="{trans 'Remove this file'}">Delete this file</a></span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
@ -27,6 +27,16 @@
|
|||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dellink {
|
||||||
|
float: right;
|
||||||
|
position: relative;
|
||||||
|
margin-top: -1.6em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dellink a {
|
||||||
|
color: #a00;
|
||||||
|
}
|
||||||
|
|
||||||
.mono {
|
.mono {
|
||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
}
|
}
|
||||||
|
BIN
www/media/idf/img/trash.png
Normal file
BIN
www/media/idf/img/trash.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 655 B |
Loading…
Reference in New Issue
Block a user