mirror of
https://github.com/haiwen/seahub.git
synced 2025-08-18 23:18:27 +00:00
rm repo_history_view.html (#6099)
* rm repo_history_view.html * rm test code * delete unnecessary code --------- Co-authored-by: 杨顺强 <978987373@qq.com>
This commit is contained in:
parent
eda0171d66
commit
9a17fe8c15
@ -81,12 +81,6 @@
|
|||||||
</ul>
|
</ul>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<div id="confirm-popup" class="hide">
|
|
||||||
<div id="confirm-con"></div>
|
|
||||||
<button id="confirm-yes">{% trans "Yes" %}</button>
|
|
||||||
<button class="simplemodal-close">{% trans "No" %}</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% block extra-hidden-dom %}
|
{% block extra-hidden-dom %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
</div><!-- wrapper -->
|
</div><!-- wrapper -->
|
||||||
@ -103,7 +97,6 @@ var app = {
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<script type="text/javascript" src="{% static "scripts/lib/jquery.min.js" %}" id="jquery"></script>{# 'id="jquery"' is for pdf file view with pdf2html #}
|
<script type="text/javascript" src="{% static "scripts/lib/jquery.min.js" %}" id="jquery"></script>{# 'id="jquery"' is for pdf file view with pdf2html #}
|
||||||
<script type="text/javascript" src="{% static "scripts/lib/jquery.simplemodal.js" %}"></script>
|
|
||||||
<script type="text/javascript" src="{{ MEDIA_URL }}js/jq.min.js"></script>
|
<script type="text/javascript" src="{{ MEDIA_URL }}js/jq.min.js"></script>
|
||||||
<script type="text/javascript" src="{{ MEDIA_URL }}js/base.js?t=1536127546642"></script>
|
<script type="text/javascript" src="{{ MEDIA_URL }}js/base.js?t=1536127546642"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
@ -1,128 +0,0 @@
|
|||||||
{% extends "base_wide_page.html" %}
|
|
||||||
|
|
||||||
{% load seahub_tags avatar_tags i18n %}
|
|
||||||
|
|
||||||
|
|
||||||
{% block extra_style %}
|
|
||||||
<style type="text/css">
|
|
||||||
.go-back { top:-3px; }
|
|
||||||
</style>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block wide_page_content %}
|
|
||||||
<h2 class="repo-snapshot-hd">{% blocktrans with repo_name=repo.props.name %}<span class="op-target">{{repo_name}}</span> Snapshot{% endblocktrans %} <span class="commit-time">({{ current_commit.props.ctime|tsstr_sec }})</span></h2>
|
|
||||||
|
|
||||||
{% if referer %}
|
|
||||||
<a href="#" class="go-back" title="{% trans "Back" %}">
|
|
||||||
<span class="icon-chevron-left"></span>
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if path == '/' %}
|
|
||||||
<div id="repo-latest-commit" class="repo-snapshot-commit">
|
|
||||||
<span class="commit-msg">{{ current_commit.props.desc|translate_commit_desc }}</span>
|
|
||||||
<span class="meta-info split">
|
|
||||||
<span class="author">
|
|
||||||
{% if current_commit.props.creator_name %}
|
|
||||||
<img src="{% avatar_url current_commit.props.creator_name 40 %}" width="20" class="avatar" />
|
|
||||||
<a class="name" href="{% url 'user_profile' current_commit.props.creator_name %}">{{ current_commit.props.creator_name|email2nickname }}</a>
|
|
||||||
{% else %}
|
|
||||||
{% trans "Unknown"%}
|
|
||||||
{% endif %}
|
|
||||||
</span>
|
|
||||||
<span class="time">{{ current_commit.props.ctime|translate_seahub_time }}</span>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
<div class="repo-file-list-topbar ovhd">
|
|
||||||
<p class="path fleft">
|
|
||||||
{% trans "Current path: "%}
|
|
||||||
{% for name, link in zipped %}
|
|
||||||
{% if not forloop.last %}
|
|
||||||
<a href="{% url 'repo_history_view' repo.id %}?commit_id={{ current_commit.id }}&p={{ link|urlencode }}" class="repo-history-view-link">{{ name }}</a> /
|
|
||||||
{% else %}
|
|
||||||
{{ name }}
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
</p>
|
|
||||||
|
|
||||||
{% if path == '/' and is_repo_owner %}
|
|
||||||
<button data-url="{% url 'repo_revert_history' repo.id %}?commit_id={{ current_commit.id }}" id="repo-revert" class="op-btn fright">{% trans "Restore"%}</button>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
<!-- /.repo-file-list-topbar -->
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<th width="5%"></th>
|
|
||||||
<th width="45%">{% trans "Name"%}</th>
|
|
||||||
<th width="23%">{% trans "Size"%}</th>
|
|
||||||
<th width="27%">{% trans "Operations"%}</th>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
{% for dirent in dir_list %}
|
|
||||||
<tr data-name="{{ dirent.obj_name }}">
|
|
||||||
<td class="alc"><img src="{{ MEDIA_URL }}img/folder-24.png" alt="{% trans "Directory"%}" /></td>
|
|
||||||
<td><a href="{% url 'repo_history_view' repo.id %}?commit_id={{ current_commit.id }}&p={{ path|urlencode }}{{ dirent.obj_name|urlencode }}" class="repo-history-view-link">{{ dirent.obj_name }}</a></td>
|
|
||||||
<td></td>
|
|
||||||
<td><a class="op vh restore-dir" data-commit_id="{{ current_commit.id }}" data-commit_path="{{ path }}{{ dirent.obj_name }}" href="#">{% trans "Restore" %}</a></td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
{% for dirent in file_list %}
|
|
||||||
<tr data-name="{{ dirent.props.obj_name }}">
|
|
||||||
<td class="alc"><img src="{{ MEDIA_URL }}img/file/{{ dirent.obj_name|file_icon_filter }}" alt="{% trans "File"%}" /></td>
|
|
||||||
<td><a class="normal" href="{% url 'view_snapshot_file' repo.props.id %}?obj_id={{ dirent.props.obj_id }}&commit_id={{ current_commit.id }}&p={{ path|urlencode }}{{ dirent.obj_name|urlencode }}" target="_blank">{{ dirent.props.obj_name }}</a></td>
|
|
||||||
<td>{{ dirent.file_size|filesizeformat }}</td>
|
|
||||||
<td>
|
|
||||||
<a class="op vh restore-file" data-commit_id="{{ current_commit.id }}" data-commit_path="{{ path }}{{ dirent.obj_name }}" href="#">{% trans "Restore" %}</a>
|
|
||||||
<a class="op vh" href="{% url 'download_file' repo.id dirent.obj_id%}?file_name={{ dirent.obj_name|urlencode }}&p={{path|urlencode}}{{ dirent.obj_name|urlencode }}">{% trans "Download" %}</a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</table>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block extra_script %}
|
|
||||||
<script type="text/javascript">
|
|
||||||
addConfirmTo($('#repo-revert'), {
|
|
||||||
'title':"{% trans "Restore Library" %}",
|
|
||||||
'con':"{% trans "Are you sure you want to restore this library?" %}",
|
|
||||||
'post':true
|
|
||||||
});
|
|
||||||
|
|
||||||
$('.restore-file, .restore-dir').on('click', function() {
|
|
||||||
var _this = $(this),
|
|
||||||
commit_id = _this.attr('data-commit_id'),
|
|
||||||
path = _this.attr('data-commit_path'),
|
|
||||||
url;
|
|
||||||
|
|
||||||
if (_this.hasClass('restore-file')) {
|
|
||||||
url = "{% url 'api-v2.1-file-view' repo.id %}" + "?p=" + encodeURIComponent(path);
|
|
||||||
} else {
|
|
||||||
url = "{% url 'api-v2.1-dir-view' repo.id %}" + "?p=" + encodeURIComponent(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
$.ajax({
|
|
||||||
url: url,
|
|
||||||
type: 'POST',
|
|
||||||
data: {'operation': 'revert', 'commit_id': commit_id},
|
|
||||||
cache: false,
|
|
||||||
dataType: 'json',
|
|
||||||
beforeSend: prepareCSRFToken,
|
|
||||||
success: function() {
|
|
||||||
var msg = "{% trans "Successfully restored {dirent_name}" %}".replace('{dirent_name}', _this.closest('tr').attr('data-name'));
|
|
||||||
feedback(msg, 'success');
|
|
||||||
},
|
|
||||||
error: ajaxErrorHandler
|
|
||||||
});
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
$('.repo-history-view-link').each(function() {
|
|
||||||
$(this).attr('href', $(this).attr('href') + '&referer=' + encodeURIComponent(location.href));
|
|
||||||
});
|
|
||||||
|
|
||||||
{% include 'snippets/go_back_js.html' %}
|
|
||||||
</script>
|
|
||||||
{% endblock %}
|
|
@ -1,14 +0,0 @@
|
|||||||
from django.urls import reverse
|
|
||||||
|
|
||||||
from seahub.test_utils import BaseTestCase
|
|
||||||
|
|
||||||
class RepoHistoryViewTest(BaseTestCase):
|
|
||||||
def setUp(self):
|
|
||||||
self.login_as(self.user)
|
|
||||||
self.url = reverse('repo_history_view', args=[self.repo.id]) + '?commit_id=' + self.repo.head_cmmt_id
|
|
||||||
|
|
||||||
def test_can_render(self):
|
|
||||||
resp = self.client.get(self.url)
|
|
||||||
self.assertEqual(200, resp.status_code)
|
|
||||||
self.assertTemplateUsed(resp, 'repo_history_view.html')
|
|
||||||
assert resp.context['user_perm'] == 'rw'
|
|
Loading…
Reference in New Issue
Block a user