diff --git a/RIGS/models.py b/RIGS/models.py index 79736131..09a70d51 100644 --- a/RIGS/models.py +++ b/RIGS/models.py @@ -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 diff --git a/RIGS/templates/RIGS/profile_detail.html b/RIGS/templates/RIGS/profile_detail.html index 56a81fba..1e7174f6 100644 --- a/RIGS/templates/RIGS/profile_detail.html +++ b/RIGS/templates/RIGS/profile_detail.html @@ -43,7 +43,8 @@
- Reset API Key + {% if user.api_key %}Reset API Key{% else %}Generate API Key{% endif %} +
@@ -51,11 +52,24 @@
API Key
-
{{user.api_key}}
+
+ {% if user.api_key %} + {{user.api_key}} + {% else %} + No API Key Generated + {% endif %} +
Calendar URL
-
https://{{ request.get_host }}{% url 'ics_calendar' api_pk=user.pk api_key=user.api_key %}
+
+ {% if user.api_key %} +
https://{{ request.get_host }}{% url 'ics_calendar' api_pk=user.pk api_key=user.api_key %}
+ {% else %} +
No API Key Generated
+ {% endif %} +
+ {% endif %}