added export view/controller/routes
This commit is contained in:
parent
bf64a59649
commit
0deb4c4ccc
|
@ -1,7 +1,7 @@
|
||||||
class UserController < ApplicationController
|
class UserController < ApplicationController
|
||||||
include ThemeHelper
|
include ThemeHelper
|
||||||
|
|
||||||
before_filter :authenticate_user!, only: %w(edit update edit_privacy update_privacy edit_theme update_theme preview_theme delete_theme data)
|
before_filter :authenticate_user!, only: %w(edit update edit_privacy update_privacy edit_theme update_theme preview_theme delete_theme data export begin_export)
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@user = User.where('LOWER(screen_name) = ?', params[:username].downcase).first!
|
@user = User.where('LOWER(screen_name) = ?', params[:username].downcase).first!
|
||||||
|
@ -156,4 +156,21 @@ class UserController < ApplicationController
|
||||||
end
|
end
|
||||||
redirect_to edit_user_theme_path
|
redirect_to edit_user_theme_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def export
|
||||||
|
if current_user.export_processing
|
||||||
|
flash[:info] = 'An export is currently in progress for this account.'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def begin_export
|
||||||
|
if current_user.can_export?
|
||||||
|
ExportWorker.perform_async(current_user.id)
|
||||||
|
flash[:success] = 'Your account is currently being exported. This will take a little while.'
|
||||||
|
else
|
||||||
|
flash[:error] = 'Nice try, kid.'
|
||||||
|
end
|
||||||
|
|
||||||
|
redirect_to user_export_path
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
- provide(:title, generate_title("Export"))
|
||||||
|
.container.j2-page
|
||||||
|
= render 'settings_tabs'
|
||||||
|
.col-md-9.col-xs-12.col-sm-8
|
||||||
|
= render 'layouts/messages'
|
||||||
|
.panel.panel-default
|
||||||
|
.panel-body
|
||||||
|
%h2 Export your data
|
||||||
|
%p
|
||||||
|
Blah blah blah introduction text because of announced
|
||||||
|
= succeed "," do
|
||||||
|
%a{href: "http://blog.retrospring.net/saying-goodbye/"} shutdown and everything
|
||||||
|
and also some more text to fill this. Oh well, just push that
|
||||||
|
button below.
|
||||||
|
%p
|
||||||
|
Please note that you can only export your data once a week. Exporting your data
|
||||||
|
will take a while, so please be patient. You will receive a question once exporting
|
||||||
|
is done.
|
||||||
|
- if current_user.can_export?
|
||||||
|
%form{action: begin_user_export_path, method: 'POST'}
|
||||||
|
%p.centre
|
||||||
|
%button#export-btn.btn.btn-lg.btn-primary{type: :submit} Export
|
||||||
|
= hidden_field_tag :authenticity_token, form_authenticity_token
|
||||||
|
- else
|
||||||
|
%p.centre
|
||||||
|
%button.btn.btn-lg.btn-primary.disabled{disabled: :disabled} Export
|
||||||
|
%p
|
||||||
|
- if current_user.export_url.nil?
|
||||||
|
Once exporting your account is done, a download link will appear here.
|
||||||
|
- else
|
||||||
|
Here is your export from
|
||||||
|
= succeed ':' do
|
||||||
|
= current_user.export_created_at
|
||||||
|
%a{href: current_user.export_url}
|
||||||
|
= File.basename current_user.export_url
|
|
@ -74,6 +74,8 @@ Rails.application.routes.draw do
|
||||||
match '/settings/privacy', to: 'user#update_privacy', via: :patch, as: :update_user_privacy
|
match '/settings/privacy', to: 'user#update_privacy', via: :patch, as: :update_user_privacy
|
||||||
|
|
||||||
match '/settings/data', to: 'user#data', via: :get, as: :user_data
|
match '/settings/data', to: 'user#data', via: :get, as: :user_data
|
||||||
|
match '/settings/export', to: 'user#export', via: :get, as: :user_export
|
||||||
|
match '/settings/export', to: 'user#begin_export', via: :post, as: :begin_user_export
|
||||||
|
|
||||||
namespace :ajax do
|
namespace :ajax do
|
||||||
match '/ask', to: 'question#create', via: :post, as: :ask
|
match '/ask', to: 'question#create', via: :post, as: :ask
|
||||||
|
|
Loading…
Reference in New Issue