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( migrations.AddField(
model_name='user', model_name='user',
name='api_token', name='api_token',
field=models.TextField(default=core.models._default_api_token, unique=True), field=models.TextField(null=True, unique=True),
), ),
migrations.AlterField( migrations.AlterField(
model_name='user', model_name='user',

View File

@ -15,10 +15,20 @@
<div> <div>
<p class="label mb-1">Personal API token</p> <p class="label mb-1">Personal API token</p>
<div class="flex justify-between"> <div class="flex justify-between">
{% if request.user.api_token %}
<span class='chip ~info !normal'>{{request.user.api_token}}</span> <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' %}"> <form method="POST" action="{% url 'dashboard:api_token_refresh' %}">
{% csrf_token %} {% csrf_token %}
<button type="submit" name="action" class="button ~neutral @high">{% trans "Refresh token" %}</button> <button type="submit" name="action" class="button ~neutral @high">
{% if request.user.api_token %}
{% trans "Refresh token" %}
{% else %}
{% trans "Generate token" %}
{% endif %}
</button>
</form> </form>
</div> </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> <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> </ul>
</p> </p>
<p>Example using cURL:</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>
</div> </div>
{% endblock %} {% endblock %}