Skip to content

Commit 8100145

Browse files
committed
Python3, Certificate generation
Done changes suggested by Kim: 1) added python3 to manage.py 2) User account activation link works multiple times without showing error(link even works when the account is activated) 3) Do not alter fields in Certificate generation are disabled for editing(using editable=False). So, that no one can alter them. These fields are system generated.
1 parent 098eeaf commit 8100145

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

manage.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
import os
33
import sys
44

@@ -9,7 +9,7 @@
99
except ImportError:
1010
# The above import may fail for some other reason. Ensure that the
1111
# issue is really that Django is missing to avoid masking other
12-
# exceptions on Python 2.
12+
# exceptions on Python 3.
1313
try:
1414
import django
1515
except ImportError:

vpn/models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,16 +206,19 @@ class GenerateCertificate(models.Model):
206206
max_length=15,
207207
default='',
208208
blank=True,
209+
editable=False,
209210
help_text="<b><a>System Generated - Do not alter</a></b>")
210211
cert_password = models.CharField(
211212
max_length=20,
212213
default='',
213214
blank=True,
215+
editable=False,
214216
help_text="<b><a>System Generated - Do not alter</a></b>")
215217
key_name = models.CharField(
216218
max_length=15,
217219
default='',
218220
blank=True,
221+
editable=False,
219222
help_text="<b><a>System Generated - Do not alter</a></b>")
220223

221224
def __unicode__(self):

vpn/views.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,8 @@ def activate(request, uidb64, token):
5656

5757
if user is not None and account_activation_token.check_token(user, token):
5858
user.is_active = True
59-
# Creating entry to profile.email_verified, as to fetch and display it to the admin.
60-
UserProfile.objects.create(username_id=uid, email_verified=True)
61-
user.save()
59+
# Creating/Updating entry to profile.email_verified, as to fetch and display it to the admin. Updating it as when user visits the same link more than once then it gives an error, so as to remove that error just added Update option along with Insert values.
60+
UserProfile.objects.filter(username_id=uid).update(email_verified=True)
6261
return HttpResponse(
6362
'<center>Thank you for your email confirmation. Now you can login your account.</center>'
6463
)

0 commit comments

Comments
 (0)