Create import/export page
This commit is contained in:
parent
74b811dd35
commit
28fb27ed93
|
@ -154,7 +154,7 @@ Here are the small sum-ups of the directory structures and their roles:
|
||||||
The code is formatted using https://github.com/psf/black, to format the code, simply run
|
The code is formatted using https://github.com/psf/black, to format the code, simply run
|
||||||
|
|
||||||
```
|
```
|
||||||
poetry run black .
|
poetry run ruff format .
|
||||||
```
|
```
|
||||||
|
|
||||||
The code is also checked with `flake8`, make sure to run `flake8` before creating the pull request by
|
The code is also checked with `flake8`, make sure to run `flake8` before creating the pull request by
|
||||||
|
|
|
@ -33,6 +33,7 @@ from .views import (
|
||||||
notification,
|
notification,
|
||||||
support,
|
support,
|
||||||
account_setting,
|
account_setting,
|
||||||
|
import_export,
|
||||||
)
|
)
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
|
@ -70,4 +71,5 @@ __all__ = [
|
||||||
"notification",
|
"notification",
|
||||||
"support",
|
"support",
|
||||||
"account_setting",
|
"account_setting",
|
||||||
|
"import_export",
|
||||||
]
|
]
|
||||||
|
|
|
@ -24,7 +24,6 @@ from app.email_utils import (
|
||||||
personal_email_already_used,
|
personal_email_already_used,
|
||||||
)
|
)
|
||||||
from app.extensions import limiter
|
from app.extensions import limiter
|
||||||
from app.jobs.export_user_data_job import ExportUserDataJob
|
|
||||||
from app.log import LOG
|
from app.log import LOG
|
||||||
from app.models import (
|
from app.models import (
|
||||||
BlockBehaviourEnum,
|
BlockBehaviourEnum,
|
||||||
|
@ -127,14 +126,6 @@ def account_setting():
|
||||||
)
|
)
|
||||||
send_reset_password_email(current_user)
|
send_reset_password_email(current_user)
|
||||||
return redirect(url_for("dashboard.account_setting"))
|
return redirect(url_for("dashboard.account_setting"))
|
||||||
elif request.form.get("form-name") == "send-full-user-report":
|
|
||||||
if ExportUserDataJob(current_user).store_job_in_db():
|
|
||||||
flash(
|
|
||||||
"You will receive your SimpleLogin data via email shortly",
|
|
||||||
"success",
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
flash("An export of your data is currently in progress", "error")
|
|
||||||
|
|
||||||
partner_sub = None
|
partner_sub = None
|
||||||
partner_name = None
|
partner_name = None
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
from flask import (
|
||||||
|
render_template,
|
||||||
|
request,
|
||||||
|
redirect,
|
||||||
|
url_for,
|
||||||
|
flash,
|
||||||
|
)
|
||||||
|
from flask_login import login_required, current_user
|
||||||
|
|
||||||
|
from app.dashboard.base import dashboard_bp
|
||||||
|
from app.dashboard.views.enter_sudo import sudo_required
|
||||||
|
from app.extensions import limiter
|
||||||
|
from app.jobs.export_user_data_job import ExportUserDataJob
|
||||||
|
from app.utils import (
|
||||||
|
CSRFValidationForm,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@dashboard_bp.route("/import_export", methods=["GET", "POST"])
|
||||||
|
@login_required
|
||||||
|
@sudo_required
|
||||||
|
@limiter.limit("5/minute", methods=["POST"])
|
||||||
|
def import_export():
|
||||||
|
csrf_form = CSRFValidationForm()
|
||||||
|
|
||||||
|
if request.method == "POST":
|
||||||
|
if not csrf_form.validate():
|
||||||
|
flash("Invalid request", "warning")
|
||||||
|
return redirect(url_for("dashboard.setting"))
|
||||||
|
if request.form.get("form-name") == "send-full-user-report":
|
||||||
|
if ExportUserDataJob(current_user).store_job_in_db():
|
||||||
|
flash(
|
||||||
|
"You will receive your SimpleLogin data via email shortly",
|
||||||
|
"success",
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
flash("An export of your data is currently in progress", "error")
|
||||||
|
|
||||||
|
return render_template(
|
||||||
|
"dashboard/import_export.html",
|
||||||
|
csrf_form=csrf_form,
|
||||||
|
)
|
|
@ -1,7 +1,7 @@
|
||||||
{% extends "default.html" %}
|
{% extends "default.html" %}
|
||||||
|
|
||||||
{% set active_page = "setting" %}
|
{% set active_page = "setting" %}
|
||||||
{% block title %}Settings{% endblock %}
|
{% block title %}Account Settings{% endblock %}
|
||||||
{% block head %}
|
{% block head %}
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
@ -120,42 +120,6 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- END WebAuthn -->
|
<!-- END WebAuthn -->
|
||||||
<!-- Alias import/export -->
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-body">
|
|
||||||
<div class="card-title">Alias import/export</div>
|
|
||||||
<div class="mb-3">
|
|
||||||
You can import your aliases created on other platforms into SimpleLogin.
|
|
||||||
You can also export your aliases to a readable csv format for a future batch import.
|
|
||||||
</div>
|
|
||||||
<a href="{{ url_for('dashboard.batch_import_route') }}"
|
|
||||||
class="btn btn-outline-primary">Batch Import</a>
|
|
||||||
<a href="{{ url_for('dashboard.alias_export_route') }}"
|
|
||||||
class="btn btn-outline-secondary">Export Aliases</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!-- END Alias import/export -->
|
|
||||||
<!-- data export -->
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-body">
|
|
||||||
<div class="card-title">SimpleLogin data export</div>
|
|
||||||
<div class="mb-3">
|
|
||||||
As per GDPR (General Data Protection Regulation) law, you can request a copy of your data which are stored on
|
|
||||||
SimpleLogin.
|
|
||||||
A zip file that contains all information will be sent to your SimpleLogin account address.
|
|
||||||
</div>
|
|
||||||
<div class="d-flex">
|
|
||||||
<div>
|
|
||||||
<form method="post">
|
|
||||||
{{ csrf_form.csrf_token }}
|
|
||||||
<input type="hidden" name="form-name" value="send-full-user-report">
|
|
||||||
<button class="btn btn-outline-info">Request your data</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!-- END data export -->
|
|
||||||
<!-- Delete account -->
|
<!-- Delete account -->
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
{% extends "default.html" %}
|
||||||
|
|
||||||
|
{% set active_page = "setting" %}
|
||||||
|
{% block title %}Import/Export{% endblock %}
|
||||||
|
{% block head %}
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.card-title {
|
||||||
|
font-size: 22px;
|
||||||
|
font-weight: 600;
|
||||||
|
margin-bottom: 3px;
|
||||||
|
}
|
||||||
|
.highlighted{
|
||||||
|
border: solid 2px #5675E2;
|
||||||
|
}
|
||||||
|
li {
|
||||||
|
margin-top: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
{% endblock %}
|
||||||
|
{% block default_content %}
|
||||||
|
|
||||||
|
<div class="col pb-3">
|
||||||
|
<!-- Alias import/export -->
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="card-title">Alias import/export</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
You can import your aliases created on other platforms into SimpleLogin.
|
||||||
|
You can also export your aliases to a readable csv format for a future batch import.
|
||||||
|
</div>
|
||||||
|
<a href="{{ url_for('dashboard.batch_import_route') }}"
|
||||||
|
class="btn btn-outline-primary">Batch Import</a>
|
||||||
|
<a href="{{ url_for('dashboard.alias_export_route') }}"
|
||||||
|
class="btn btn-outline-secondary">Export Aliases</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- END Alias import/export -->
|
||||||
|
<!-- data export -->
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="card-title">SimpleLogin data export</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
As per GDPR (General Data Protection Regulation) law, you can request a copy of your data which are stored on
|
||||||
|
SimpleLogin.
|
||||||
|
A zip file that contains all information will be sent to your SimpleLogin account address.
|
||||||
|
</div>
|
||||||
|
<div class="d-flex">
|
||||||
|
<div>
|
||||||
|
<form method="post">
|
||||||
|
{{ csrf_form.csrf_token }}
|
||||||
|
<input type="hidden" name="form-name" value="send-full-user-report">
|
||||||
|
<button class="btn btn-outline-info">Request your data</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- END data export -->
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
{% block script %}
|
||||||
|
|
||||||
|
<script>
|
||||||
|
let anchor = window.location.hash;
|
||||||
|
$(anchor).addClass("highlighted")
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
|
@ -152,6 +152,10 @@
|
||||||
href="{{ url_for('dashboard.account_setting') }}">
|
href="{{ url_for('dashboard.account_setting') }}">
|
||||||
<i class="dropdown-icon fa fa-user"></i> Account settings
|
<i class="dropdown-icon fa fa-user"></i> Account settings
|
||||||
</a>
|
</a>
|
||||||
|
<a class="dropdown-item mb-3"
|
||||||
|
href="{{ url_for('dashboard.import_export') }}">
|
||||||
|
<i class="dropdown-icon fa fa-download"></i> Import/export
|
||||||
|
</a>
|
||||||
<a class="dropdown-item" href="{{ url_for('auth.logout') }}">
|
<a class="dropdown-item" href="{{ url_for('auth.logout') }}">
|
||||||
<i class="dropdown-icon fe fe-log-out"></i> Sign out
|
<i class="dropdown-icon fe fe-log-out"></i> Sign out
|
||||||
</a>
|
</a>
|
||||||
|
|
Loading…
Reference in New Issue