This repository has been archived by the owner on Apr 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes to be committed: modified: .vscode/settings.json modified: core/apps.py modified: core/migrations/0001_initial.py modified: core/migrations/0002_prefixes.py modified: core/migrations/0003_auto_20220330_2122.py modified: core/migrations/0004_auto_20220716_1651.py modified: core/models.py modified: core/serializers.py modified: core/tests/test_models.py modified: core/urls.py modified: core/views.py modified: docs/source/conf.py modified: manage.py modified: portalusers/asgi.py modified: portalusers/settings.py modified: portalusers/urls.py modified: portalusers/utils.py modified: portalusers/wsgi.py modified: simple_api_info_fill.py
- Loading branch information
1 parent
ebe049d
commit 749bd72
Showing
19 changed files
with
574 additions
and
430 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,13 @@ | ||
{ | ||
"python.linting.pylintEnabled": true, | ||
"python.linting.enabled": true | ||
"python.linting.enabled": true, | ||
"python.linting.pylintArgs": [ | ||
"--django-settings-module=portalusers.settings", | ||
"--load-plugins=pylint_django", | ||
], | ||
"django.snippets.exclude": [ | ||
|
||
"cms", | ||
"wagtail" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,33 +12,42 @@ | |
from rest_framework import status | ||
from rest_framework.response import Response | ||
|
||
|
||
@receiver(reset_password_token_created) | ||
def password_reset_token_created(sender, instance, reset_password_token, *args, **kwargs): | ||
def password_reset_token_created( | ||
sender, instance, reset_password_token, *args, **kwargs | ||
): | ||
""" | ||
Create the token for a password reset. | ||
""" | ||
email_plaintext_message = "{}?token={}".format(reverse( | ||
'password_reset:reset-password-request'), reset_password_token.key) | ||
email_plaintext_message = "{}?token={}".format( | ||
reverse("password_reset:reset-password-request"), reset_password_token.key | ||
) | ||
|
||
try: | ||
send_mail( | ||
subject='Password reset for BioCompute Portal', | ||
message= email_plaintext_message, | ||
subject="Password reset for BioCompute Portal", | ||
message=email_plaintext_message, | ||
html_message=email_plaintext_message, | ||
from_email='[email protected]', | ||
from_email="[email protected]", | ||
recipient_list=[reset_password_token.user.email], | ||
fail_silently=False, | ||
) | ||
|
||
except Exception as error: | ||
print('activation_link', reset_password_token) | ||
print("activation_link", reset_password_token) | ||
# print('ERROR: ', error) | ||
# TODO: Should handle when the send_mail function fails? | ||
# return Response(status=status.HTTP_500_INTERNAL_SERVER_ERROR, data={ | ||
# "message": "Not able to send authentication email: {}".format(error)}) | ||
return Response(status=status.HTTP_201_CREATED, | ||
data={"message": "Reset token has been requested but email was not sent."\ | ||
f" Check with your database administrator for your token. {error}"}) | ||
return Response( | ||
status=status.HTTP_201_CREATED, | ||
data={ | ||
"message": "Reset token has been requested but email was not sent." | ||
f" Check with your database administrator for your token. {error}" | ||
}, | ||
) | ||
|
||
|
||
class Profile(models.Model): | ||
"""Profile | ||
|
@@ -55,14 +64,16 @@ class Profile(models.Model): | |
orcid: | ||
User ORCID | ||
""" | ||
|
||
username = models.OneToOneField(User, on_delete=models.CASCADE) | ||
public = models.BooleanField(blank = True, default=False) | ||
affiliation = models.CharField(blank = True, max_length = 1000) | ||
orcid = models.CharField(blank = True, max_length = 1000) | ||
public = models.BooleanField(blank=True, default=False) | ||
affiliation = models.CharField(blank=True, max_length=1000) | ||
orcid = models.CharField(blank=True, max_length=1000) | ||
|
||
def __str__(self): | ||
"""String for representing the Profile model (in Admin site etc.).""" | ||
return str(f'{self.username}') | ||
return str(f"{self.username}") | ||
|
||
|
||
class ApiInfo(models.Model): | ||
"""API Information | ||
|
@@ -86,20 +97,19 @@ class ApiInfo(models.Model): | |
""" | ||
|
||
local_username = models.ForeignKey( | ||
User, | ||
on_delete = models.CASCADE, | ||
related_name = 'custom_user' | ||
User, on_delete=models.CASCADE, related_name="custom_user" | ||
) | ||
username = models.CharField(blank = True, max_length = 1000) | ||
hostname = models.CharField(blank = True, max_length = 15) | ||
human_readable_hostname = models.CharField(blank = True, max_length = 1000) | ||
public_hostname = models.CharField(blank = True, max_length = 1000) | ||
token = models.CharField(blank = True, max_length = 1000) | ||
username = models.CharField(blank=True, max_length=1000) | ||
hostname = models.CharField(blank=True, max_length=15) | ||
human_readable_hostname = models.CharField(blank=True, max_length=1000) | ||
public_hostname = models.CharField(blank=True, max_length=1000) | ||
token = models.CharField(blank=True, max_length=1000) | ||
other_info = models.JSONField() | ||
|
||
def __str__(self): | ||
"""String for representing the ApiInfo model (in Admin site etc.).""" | ||
return str(f'{self.username} at {self.hostname}') | ||
return str(f"{self.username} at {self.hostname}") | ||
|
||
|
||
class Prefixes(models.Model): | ||
"""Prefix Table: core_prefixes | ||
|
@@ -112,14 +122,10 @@ class Prefixes(models.Model): | |
registration_certificate: str | ||
""" | ||
|
||
prefix = models.CharField(max_length = 5, primary_key=True, unique=True) | ||
username = models.ForeignKey( | ||
User, | ||
on_delete=models.CASCADE, | ||
to_field="username" | ||
) | ||
prefix = models.CharField(max_length=5, primary_key=True, unique=True) | ||
username = models.ForeignKey(User, on_delete=models.CASCADE, to_field="username") | ||
registration_date = models.DateTimeField() | ||
registration_certificate = models.CharField(max_length = 1000) | ||
registration_certificate = models.CharField(max_length=1000) | ||
|
||
def __str__(self): | ||
"""String for representing the Prefix (in Admin site etc.).""" | ||
|
Oops, something went wrong.