Fix migrations

This commit is contained in:
R. Miles McCain 2022-09-15 22:24:29 -07:00
parent 767fd49969
commit c34388e6c9
3 changed files with 14 additions and 4 deletions

View File

@ -14,7 +14,7 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='user',
name='api_token',
field=models.TextField(default=core.models._default_api_token, unique=True),
field=models.TextField(null=True, unique=True),
),
migrations.AlterField(
model_name='user',

View File

@ -15,10 +15,20 @@
<div>
<p class="label mb-1">Personal API token</p>
<div class="flex justify-between">
{% if request.user.api_token %}
<span class='chip ~info !normal'>{{request.user.api_token}}</span>
{% else %}
<span>Token not generated</span>
{% endif %}
<form method="POST" action="{% url 'dashboard:api_token_refresh' %}">
{% csrf_token %}
<button type="submit" name="action" class="button ~neutral @high">{% trans "Refresh token" %}</button>
{% csrf_token %}
<button type="submit" name="action" class="button ~neutral @high">
{% if request.user.api_token %}
{% trans "Refresh token" %}
{% else %}
{% trans "Generate token" %}
{% endif %}
</button>
</form>
</div>
<p class="support mt-1">To learn more about the API, see our <a href="https://github.com/milesmcc/shynet/blob/master/GUIDE.md#api">API guide</a>.</p>

View File

@ -47,7 +47,7 @@
</ul>
</p>
<p>Example using cURL:</p>
<code class="text-sm">curl -H 'Authorization: Token {{request.user.api_token}}' '{{script_protocol}}{{request.get_host}}{% url 'api:services' %}?uuid={{object.uuid}}&startDate=2021-01-01&endDate=2050-01-01'</code>
<code class="text-sm">curl -H 'Authorization: Token (your API token, available on security page)' '{{script_protocol}}{{request.get_host}}{% url 'api:services' %}?uuid={{object.uuid}}&startDate=2021-01-01&endDate=2050-01-01'</code>
</div>
</div>
{% endblock %}