diff --git a/seahub/api2/endpoints/deleted_repos.py b/seahub/api2/endpoints/deleted_repos.py
new file mode 100644
index 0000000000..77826c9a7e
--- /dev/null
+++ b/seahub/api2/endpoints/deleted_repos.py
@@ -0,0 +1,70 @@
+import logging
+
+from rest_framework.authentication import SessionAuthentication
+from rest_framework.permissions import IsAuthenticated
+from rest_framework.response import Response
+from rest_framework import status
+from django.template.defaultfilters import filesizeformat
+from seaserv import seafile_api
+
+from pysearpc import SearpcError
+
+from seahub.api2.throttling import UserRateThrottle
+from seahub.api2.authentication import TokenAuthentication
+from seahub.api2.base import APIView
+from seahub.api2.utils import api_error
+from seahub.base.templatetags.seahub_tags import email2nickname, email2contact_email
+from seahub.utils.timeutils import timestamp_to_isoformat_timestr
+
+logger = logging.getLogger(__name__)
+
+
+class DeletedRepos(APIView):
+ authentication_classes = (TokenAuthentication, SessionAuthentication)
+ permission_classes = (IsAuthenticated,)
+ throttle_classes = (UserRateThrottle,)
+
+ def get(self, request):
+ """
+ get the deleted-repos of owner
+ """
+ trashs_json = []
+ email = request.user.username
+
+ trash_repos = seafile_api.get_trash_repos_by_owner(email)
+ for r in trash_repos:
+ trash = {
+ "repo_id": r.repo_id,
+ "owner_email": email,
+ "owner_name": email2nickname(email),
+ "owner_contact_email": email2contact_email(email),
+ "repo_name": r.repo_name,
+ "org_id": r.org_id,
+ "head_commit_id": r.head_id,
+ "encrypted": r.encrypted,
+ "del_time": timestamp_to_isoformat_timestr(r.del_time),
+ "size": r.size,
+ }
+ trashs_json.append(trash)
+ return Response(trashs_json)
+
+ def post(self, request):
+ """
+ restore deleted-repo
+ return:
+ return True if success, otherwise api_error
+ """
+ post_data = request.POST
+ repo_id = post_data.get('repo_id', '')
+ if not repo_id:
+ error_msg = "repo_id invalid"
+ return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
+
+ try:
+ seafile_api.restore_repo_from_trash(repo_id)
+ except SearpcError as e:
+ logger.error(e)
+ error = "Internal Server Error"
+ return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
+
+ return Response({"success": True})
diff --git a/seahub/templates/js/templates.html b/seahub/templates/js/templates.html
index 723d0cfa46..9fa315d0da 100644
--- a/seahub/templates/js/templates.html
+++ b/seahub/templates/js/templates.html
@@ -154,6 +154,30 @@
+
+
+
+
+
+
+
+
+