adding api key to export settings page
This commit is contained in:
@@ -7,37 +7,38 @@
|
||||
{% block main %}
|
||||
<h1>Import and Export Settings for {{ rower.user.first_name }} {{ rower.user.last_name }}</h1>
|
||||
|
||||
<p>You are currently connected to:
|
||||
{% if rower.c2token is not None and rower.c2token != '' %}
|
||||
Concept2 Logbook,
|
||||
{% endif %}
|
||||
{% if rower.nktoken is not None and rower.nktoken != '' %}
|
||||
NK Logbook,
|
||||
{% endif %}
|
||||
{% if rower.sporttrackstoken is not None and rower.sporttrackstoken != '' %}
|
||||
SportTracks,
|
||||
{% endif %}
|
||||
{% if rower.tptoken is not None and rower.tptoken != '' %}
|
||||
TrainingPeaks,
|
||||
{% endif %}
|
||||
{% if rower.polartoken is not None and rower.polartoken != '' %}
|
||||
Polar,
|
||||
{% endif %}
|
||||
{% if rower.garmintoken is not None and rower.garmintoken != '' %}
|
||||
Garmin Connect,
|
||||
{% endif %}
|
||||
{% if rower.stravatoken is not None and rower.stravatoken != '' %}
|
||||
Strava,
|
||||
{% endif %}
|
||||
{% if rower.rp3token is not None and rower.rp3token != '' %}
|
||||
RP3
|
||||
{% endif %}
|
||||
{% if rower.rojabo_token is not None and rower.rojabo_token != '' %}
|
||||
Rojabo
|
||||
{% endif %}
|
||||
|
||||
</p>
|
||||
|
||||
<ul class="main-content">
|
||||
<li class="grid_2">
|
||||
<p>You are currently connected to:
|
||||
{% if rower.c2token is not None and rower.c2token != '' %}
|
||||
Concept2 Logbook,
|
||||
{% endif %}
|
||||
{% if rower.nktoken is not None and rower.nktoken != '' %}
|
||||
NK Logbook,
|
||||
{% endif %}
|
||||
{% if rower.sporttrackstoken is not None and rower.sporttrackstoken != '' %}
|
||||
SportTracks,
|
||||
{% endif %}
|
||||
{% if rower.tptoken is not None and rower.tptoken != '' %}
|
||||
TrainingPeaks,
|
||||
{% endif %}
|
||||
{% if rower.polartoken is not None and rower.polartoken != '' %}
|
||||
Polar,
|
||||
{% endif %}
|
||||
{% if rower.garmintoken is not None and rower.garmintoken != '' %}
|
||||
Garmin Connect,
|
||||
{% endif %}
|
||||
{% if rower.stravatoken is not None and rower.stravatoken != '' %}
|
||||
Strava,
|
||||
{% endif %}
|
||||
{% if rower.rp3token is not None and rower.rp3token != '' %}
|
||||
RP3
|
||||
{% endif %}
|
||||
{% if rower.rojabo_token is not None and rower.rojabo_token != '' %}
|
||||
Rojabo
|
||||
{% endif %}
|
||||
</p>
|
||||
|
||||
{% if form.errors %}
|
||||
<p style="color: red;">
|
||||
Please correct the error{{ form.errors|pluralize }} below.
|
||||
@@ -71,24 +72,57 @@
|
||||
a workout on Strava. If you want Deletions to propagate to Rowsandall, tick the Strava Auto Delete
|
||||
check box.
|
||||
</p>
|
||||
<p>Click on one of the icons below to connect to the service of your
|
||||
choice or to renew the authorization.</p>
|
||||
<p><a href="/rowers/me/stravaauthorize/"><img src="/static/img/ConnectWithStrava.png" alt="connect with strava" width="120"></a></p>
|
||||
<p><a href="/rowers/me/c2authorize/"><img src="/static/img/blueC2logo.png" alt="connect with Concept2" width="120"></a></p>
|
||||
<p><a href="/rowers/me/nkauthorize/"><img src="/static/img/NKLiNKLogbook.png" alt="connect with NK Logbook" width="120"></a></p>
|
||||
<p><a href="/rowers/me/sporttracksauthorize/"><img src="/static/img/sporttracks-button.png" alt="connect with SportTracks" width="120"></a></p>
|
||||
<p><a href="/rowers/me/polarauthorize/"><img src="/static/img/Polar_connectwith_btn_white.png"
|
||||
</li>
|
||||
<li class="grid_2">
|
||||
{% if grants %}
|
||||
<h2>Applications</h2>
|
||||
<table width="100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Application</th>
|
||||
<th>Scope</th>
|
||||
<th>Revoke</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for grant in grants %}
|
||||
<tr>
|
||||
<td>{{ grant.application }}</td>
|
||||
<td>{{ grant.scope }}</td>
|
||||
<td>
|
||||
<a href="/rowers/me/revokeapp/{{ grant.application.id }}/">Revoke</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endif %}
|
||||
<h2>API Key</h2>
|
||||
<p>{{ apikey }}</p>
|
||||
<p>
|
||||
<a href="/rowers/me/regenerateapikey/">Regenerate</a>
|
||||
</p>
|
||||
This API key can be used to access the Rowsandall API. It is used by some third party applications to access your data. Keep it secret.
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
<p>Click on one of the icons below to connect to the service of your
|
||||
choice or to renew the authorization.</p>
|
||||
<p><a href="/rowers/me/stravaauthorize/"><img src="/static/img/ConnectWithStrava.png" alt="connect with strava" width="120"></a></p>
|
||||
<p><a href="/rowers/me/c2authorize/"><img src="/static/img/blueC2logo.png" alt="connect with Concept2" width="120"></a></p>
|
||||
<p><a href="/rowers/me/nkauthorize/"><img src="/static/img/NKLiNKLogbook.png" alt="connect with NK Logbook" width="120"></a></p>
|
||||
<p><a href="/rowers/me/sporttracksauthorize/"><img src="/static/img/sporttracks-button.png" alt="connect with SportTracks" width="120"></a></p>
|
||||
<p><a href="/rowers/me/polarauthorize/"><img src="/static/img/Polar_connectwith_btn_white.png"
|
||||
alt="connect with Polar" width="130"></a></p>
|
||||
<p><a href="/rowers/me/tpauthorize/"><img src="/static/img/TP_logo_horz_2_color.png"
|
||||
alt="connect with Polar" width="130"></a></p>
|
||||
|
||||
<p><a href="/rowers/me/garminauthorize"><img src="/static/img/garmin_badge_130.png"
|
||||
alt="connect with Garmin" width="130"></a></p>
|
||||
<p><a href="/rowers/me/rp3authorize"><img src="/static/img/logo-rp3-full-black.png"
|
||||
alt="connect with RP3" width="130"></a></p>
|
||||
<p><a href="/rowers/me/rojaboauthorize"><img src="/static/img/rojabo.png"
|
||||
alt="connect with Rojabo" width="130"></a></p>
|
||||
|
||||
<p><a href="/rowers/me/tpauthorize/"><img src="/static/img/TP_logo_horz_2_color.png"
|
||||
alt="connect with Polar" width="130"></a></p>
|
||||
|
||||
<p><a href="/rowers/me/garminauthorize"><img src="/static/img/garmin_badge_130.png"
|
||||
alt="connect with Garmin" width="130"></a></p>
|
||||
<p><a href="/rowers/me/rp3authorize"><img src="/static/img/logo-rp3-full-black.png"
|
||||
alt="connect with RP3" width="130"></a></p>
|
||||
<p><a href="/rowers/me/rojaboauthorize"><img src="/static/img/rojabo.png"
|
||||
alt="connect with Rojabo" width="130"></a></p>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
||||
@@ -520,10 +520,19 @@ def rower_exportsettings_view(request, userid=0):
|
||||
}
|
||||
]
|
||||
|
||||
grants = AccessToken.objects.filter(user=request.user)
|
||||
try:
|
||||
apikey = APIKey.objects.get(user=request.user)
|
||||
except APIKey.DoesNotExist:
|
||||
apikey = APIKey.objects.create(user=request.user)
|
||||
|
||||
|
||||
return render(request, 'rower_exportsettings.html',
|
||||
{'form': form,
|
||||
'rower': r,
|
||||
'breadcrumbs': breadcrumbs,
|
||||
'grants': grants,
|
||||
'apikey': apikey.key,
|
||||
})
|
||||
|
||||
|
||||
@@ -651,6 +660,7 @@ def rower_edit_view(request, rowerid=0, userid=0, message=""):
|
||||
|
||||
@login_required()
|
||||
def rower_regenerate_apikey(request):
|
||||
referer = request.META['HTTP_REFERER']
|
||||
try:
|
||||
apikey = APIKey.objects.get(user=request.user)
|
||||
except APIKey.DoesNotExist:
|
||||
@@ -658,7 +668,7 @@ def rower_regenerate_apikey(request):
|
||||
|
||||
apikey.regenerate_key()
|
||||
|
||||
return HttpResponseRedirect(reverse('rower_edit_view'))
|
||||
return HttpResponseRedirect(referer)
|
||||
|
||||
#simple initial settings page
|
||||
@login_required()
|
||||
|
||||
Reference in New Issue
Block a user