mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-17 13:32:15 +00:00
Made it work for users that already exist in database
This commit is contained in:
@@ -16,8 +16,8 @@ from decimal import Decimal
|
||||
class Profile(AbstractUser):
|
||||
initials = models.CharField(max_length=5, unique=True, null=True, blank=False)
|
||||
phone = models.CharField(max_length=13, null=True, blank=True)
|
||||
api_key = models.CharField(max_length=40,blank=False,editable=True,default=lambda: make_api_key())
|
||||
|
||||
api_key = models.CharField(max_length=40,blank=True,editable=False, null=True)
|
||||
|
||||
@classmethod
|
||||
def make_api_key(cls):
|
||||
size=20
|
||||
|
||||
@@ -43,7 +43,8 @@
|
||||
|
||||
<div class="pull-right">
|
||||
<a href="{% url 'reset_api_key' %}" class="btn">
|
||||
Reset API Key <span class="glyphicon glyphicon-repeat"></span>
|
||||
{% if user.api_key %}Reset API Key{% else %}Generate API Key{% endif %}
|
||||
<span class="glyphicon glyphicon-repeat"></span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@@ -51,11 +52,24 @@
|
||||
|
||||
<dl class="dl-horizontal">
|
||||
<dt>API Key</dt>
|
||||
<dd>{{user.api_key}}</dd>
|
||||
<dd>
|
||||
{% if user.api_key %}
|
||||
{{user.api_key}}
|
||||
{% else %}
|
||||
No API Key Generated
|
||||
{% endif %}
|
||||
</dd>
|
||||
|
||||
<dt>Calendar URL</dt>
|
||||
<dd><pre>https://{{ request.get_host }}{% url 'ics_calendar' api_pk=user.pk api_key=user.api_key %}</pre></dd>
|
||||
<dd>
|
||||
{% if user.api_key %}
|
||||
<pre>https://{{ request.get_host }}{% url 'ics_calendar' api_pk=user.pk api_key=user.api_key %}</pre>
|
||||
{% else %}
|
||||
<pre>No API Key Generated</pre>
|
||||
{% endif %}
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user