mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-08-31 21:41:33 +00:00
Adding export user's opml functionality for staff.
This commit is contained in:
parent
1d81521af6
commit
abab00f0d6
2 changed files with 12 additions and 2 deletions
|
@ -7,6 +7,7 @@ from oauth2client.client import OAuth2WebServerFlow, FlowExchangeError
|
|||
from bson.errors import InvalidStringData
|
||||
import uuid
|
||||
from django.contrib.sites.models import Site
|
||||
from django.contrib.auth.models import User
|
||||
# from django.db import IntegrityError
|
||||
from django.http import HttpResponse, HttpResponseRedirect
|
||||
from django.conf import settings
|
||||
|
@ -75,12 +76,15 @@ def opml_upload(request):
|
|||
|
||||
def opml_export(request):
|
||||
user = get_user(request)
|
||||
now = datetime.datetime.now()
|
||||
if request.REQUEST.get('user_id') and user.is_staff:
|
||||
user = User.objects.get(pk=request.REQUEST['user_id'])
|
||||
exporter = OPMLExporter(user)
|
||||
opml = exporter.process()
|
||||
now = datetime.datetime.now()
|
||||
|
||||
response = HttpResponse(opml, mimetype='text/xml')
|
||||
response['Content-Disposition'] = 'attachment; filename=NewsBlur Subscriptions - %s' % (
|
||||
response['Content-Disposition'] = 'attachment; filename=NewsBlur Subscriptions - %s - %s' % (
|
||||
user.username,
|
||||
now.strftime('%Y-%m-%d')
|
||||
)
|
||||
|
||||
|
|
|
@ -83,6 +83,7 @@ _.extend(NEWSBLUR.ReaderUserAdmin.prototype, {
|
|||
}
|
||||
|
||||
$actions.append($.make('div', { className: "NB-modal-submit-button NB-modal-submit-green NB-admin-action-history", style: "float: left" }, "Update History"));
|
||||
$actions.append($.make('div', { className: "NB-modal-submit-button NB-modal-submit-green NB-admin-action-opml", style: "float: left" }, "OPML"));
|
||||
|
||||
$statistics.append($.make('dl', [
|
||||
$.make('dt', 'Stripe Id:'),
|
||||
|
@ -154,6 +155,11 @@ _.extend(NEWSBLUR.ReaderUserAdmin.prototype, {
|
|||
$(".NB-admin-action-history").replaceWith($.make('div', 'Error: ' + JSON.stringify(data)));
|
||||
});
|
||||
});
|
||||
$.targetIs(e, { tagSelector: '.NB-admin-action-opml' }, function($t, $p) {
|
||||
e.preventDefault();
|
||||
|
||||
window.location.href = NEWSBLUR.URLs['opml-export'] + "?user_id=" + self.user.get('user_id');
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue