Client - disable registration - fix #36

This commit is contained in:
Sam 2019-08-25 12:50:42 +02:00
parent 5b6a94fb85
commit a7de5dd52c
14 changed files with 111 additions and 80 deletions

View File

@ -1,8 +1,8 @@
export REACT_APP_API_URL = http://$(HOST):$(API_PORT)
export REACT_APP_THUNDERFOREST_API_KEY=
export REACT_APP_GPX_LIMIT_IMPORT=10
export REACT_APP_ALLOW_REGISTRATION=true
export WEATHER_API=
export FT_ALLOW_REGISTRATION=true
# for dev env
export CODACY_PROJECT_TOKEN=

View File

@ -1,8 +1,8 @@
Features
########
Features list
~~~~~~~~~~~~~
List
~~~~
- Account creation (only standard user, not admin)
- 6 sports supported:
- Cycling (Sport)
@ -22,6 +22,7 @@ Features list
- longest duration
- maximum speed
- Activities list and filter
- User registration can be disabled.
**Notes:**

View File

@ -46,7 +46,8 @@ Dev environment
- Update **Makefile.config** file if needed and copy/paste the
**ThunderForest** and **Dark Sky** API keys value in
**Makefile.custom.config** file (see example)
**Makefile.custom.config** file (see example). User registration can
also be disabled in **Makefile.custom.config**.
- Install Python virtualenv, React and all related packages and
initialize the database:
@ -82,7 +83,8 @@ Prod environment
- Update **Makefile.config** file if needed and copy/paste the
**ThunderForest** and **Dark Sky** API keys value in
**Makefile.custom.config** file (see example)
**Makefile.custom.config** file (see example). User registration can
also be disabled in **Makefile.custom.config**.
- Install Python virtualenv, React and all related packages and
initialize the database:

View File

@ -75,7 +75,7 @@
role="menu"
aria-labelledby="dLabelLocalToc"><ul>
<li><a class="reference internal" href="#">Features</a><ul>
<li><a class="reference internal" href="#features-list">Features list</a></li>
<li><a class="reference internal" href="#list">List</a></li>
<li><a class="reference internal" href="#dashboard">Dashboard</a></li>
<li><a class="reference internal" href="#activity-workout-detail">Activity/workout detail</a></li>
<li><a class="reference internal" href="#activities-workouts-list">Activities/workouts list</a></li>
@ -131,8 +131,8 @@
<div class="section" id="features">
<h1>Features<a class="headerlink" href="#features" title="Permalink to this headline"></a></h1>
<div class="section" id="features-list">
<h2>Features list<a class="headerlink" href="#features-list" title="Permalink to this headline"></a></h2>
<div class="section" id="list">
<h2>List<a class="headerlink" href="#list" title="Permalink to this headline"></a></h2>
<ul class="simple">
<li><p>Account creation (only standard user, not admin)</p></li>
<li><dl class="simple">
@ -163,6 +163,7 @@
</dl>
</li>
<li><p>Activities list and filter</p></li>
<li><p>User registration can be disabled.</p></li>
</ul>
<p><strong>Notes:</strong></p>
<ul class="simple">

View File

@ -160,7 +160,7 @@ Map</a>.</div>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="features.html">Features</a><ul>
<li class="toctree-l2"><a class="reference internal" href="features.html#features-list">Features list</a></li>
<li class="toctree-l2"><a class="reference internal" href="features.html#list">List</a></li>
<li class="toctree-l2"><a class="reference internal" href="features.html#dashboard">Dashboard</a></li>
<li class="toctree-l2"><a class="reference internal" href="features.html#activity-workout-detail">Activity/workout detail</a></li>
<li class="toctree-l2"><a class="reference internal" href="features.html#activities-workouts-list">Activities/workouts list</a></li>

View File

@ -191,7 +191,8 @@ $ <span class="nb">cd</span> FitTrackee
<ul class="simple">
<li><p>Update <strong>Makefile.config</strong> file if needed and copy/paste the
<strong>ThunderForest</strong> and <strong>Dark Sky</strong> API keys value in
<strong>Makefile.custom.config</strong> file (see example)</p></li>
<strong>Makefile.custom.config</strong> file (see example). User registration can
also be disabled in <strong>Makefile.custom.config</strong>.</p></li>
<li><p>Install Python virtualenv, React and all related packages and
initialize the database:</p></li>
</ul>
@ -226,7 +227,8 @@ $ <span class="nb">cd</span> FitTrackee
<ul class="simple">
<li><p>Update <strong>Makefile.config</strong> file if needed and copy/paste the
<strong>ThunderForest</strong> and <strong>Dark Sky</strong> API keys value in
<strong>Makefile.custom.config</strong> file (see example)</p></li>
<strong>Makefile.custom.config</strong> file (see example). User registration can
also be disabled in <strong>Makefile.custom.config</strong>.</p></li>
<li><p>Install Python virtualenv, React and all related packages and
initialize the database:</p></li>
</ul>

File diff suppressed because one or more lines are too long

View File

@ -1,8 +1,8 @@
Features
########
Features list
~~~~~~~~~~~~~
List
~~~~
- Account creation (only standard user, not admin)
- 6 sports supported:
- Cycling (Sport)
@ -22,6 +22,7 @@ Features list
- longest duration
- maximum speed
- Activities list and filter
- User registration can be disabled.
**Notes:**

View File

@ -46,7 +46,8 @@ Dev environment
- Update **Makefile.config** file if needed and copy/paste the
**ThunderForest** and **Dark Sky** API keys value in
**Makefile.custom.config** file (see example)
**Makefile.custom.config** file (see example). User registration can
also be disabled in **Makefile.custom.config**.
- Install Python virtualenv, React and all related packages and
initialize the database:
@ -82,7 +83,8 @@ Prod environment
- Update **Makefile.config** file if needed and copy/paste the
**ThunderForest** and **Dark Sky** API keys value in
**Makefile.custom.config** file (see example)
**Makefile.custom.config** file (see example). User registration can
also be disabled in **Makefile.custom.config**.
- Install Python virtualenv, React and all related packages and
initialize the database:

View File

@ -17,7 +17,7 @@ class BaseConfig:
PICTURE_ALLOWED_EXTENSIONS = {'jpg', 'png', 'gif'}
ACTIVITY_ALLOWED_EXTENSIONS = {'gpx', 'zip'}
REGISTRATION_ALLOWED = (
False if os.getenv('FT_ALLOW_REGISTRATION') == "false" else True
False if os.getenv('REACT_APP_ALLOW_REGISTRATION') == "false" else True
)

View File

@ -13,6 +13,7 @@ os.environ["APP_SETTINGS"] = 'fittrackee_api.config.TestingConfig'
@pytest.fixture
def app():
app = create_app()
app.config['REGISTRATION_ALLOWED'] = True
with app.app_context():
db.create_all()
yield app

View File

@ -1,6 +1,9 @@
import React from 'react'
import { Helmet } from 'react-helmet'
import { history } from '../../index'
import { isRegistrationAllowed } from '../../utils'
export default function Form (props) {
return (
<div>
@ -15,6 +18,19 @@ export default function Form (props) {
<div className="col-md-3" />
<div className="col-md-6">
<hr /><br />
{props.formType === 'register' && !isRegistrationAllowed ? (
<div className="card">
<div className="card-body">Registration is disabled.</div>
<div className="card-body">
<button
type="submit"
className="btn btn-secondary btn-lg btn-block"
onClick={() => history.go(-1)}
>Back
</button>
</div>
</div>
) : (
<form onSubmit={event =>
props.handleUserFormSubmit(event, props.formType)}
>
@ -72,6 +88,7 @@ export default function Form (props) {
value="Submit"
/>
</form>
)}
</div>
<div className="col-md-3" />
</div>

View File

@ -7,6 +7,8 @@ export const thunderforestApiKey = `${
process.env.REACT_APP_THUNDERFOREST_API_KEY
}`
export const gpxLimit = `${process.env.REACT_APP_GPX_LIMIT_IMPORT}`
export const isRegistrationAllowed =
process.env.REACT_APP_ALLOW_REGISTRATION !== 'false'
export const isLoggedIn = () => !!window.localStorage.authToken

View File

@ -1,2 +1,4 @@
[pytest]
norecursedirs = fittrackee_api/.venv
filterwarnings =
ignore::DeprecationWarning