Skip to content

Commit a0f51bc

Browse files
authored
Merge pull request #120 from UCL-ARC/improving-local
improving local dev and testing
2 parents 8855008 + 61f75a4 commit a0f51bc

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

mod_app/utils/mixins.py

+17-11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from django.conf import settings
12
from django.template.loader import get_template
23
from django.utils.html import format_html
34

@@ -50,21 +51,26 @@ def __init__(self, *args, **kwargs):
5051
self.readonly_fields += ("s3_browser_button",)
5152

5253
def s3_browser_button(self, obj):
53-
button_html = get_template("components/s3_browse_button.html")
54-
return button_html.render()
54+
if settings.ENVIRONMENT != "local":
55+
button_html = get_template("components/s3_browse_button.html")
56+
return button_html.render()
57+
else:
58+
button_html = "Not available locally"
59+
return button_html
5560

5661

5762
class EmailMixin:
5863
def save_model(self, request, obj, form, change):
5964
super().save_model(request, obj, form, change)
60-
61-
# Check if it's a new instance or an update
62-
if change:
63-
build_and_send_email(request, obj, "updated")
64-
else:
65-
# new instance
66-
build_and_send_email(request, obj, "added")
65+
if settings.ENVIRONMENT != "local":
66+
# Check if it's a new instance or an update
67+
if change:
68+
build_and_send_email(request, obj, "updated")
69+
else:
70+
# new instance
71+
build_and_send_email(request, obj, "added")
6772

6873
def delete_model(self, request, obj):
69-
build_and_send_email(request, obj, "deleted")
70-
super().delete_model(request, obj)
74+
if settings.ENVIRONMENT != "local":
75+
build_and_send_email(request, obj, "deleted")
76+
super().delete_model(request, obj)

museum_of_dreams_project/settings/local.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from .base import *
22

33
SECRET_KEY = "notasecret"
4+
ENVIRONMENT = "local"
45

56
ALLOWED_HOSTS = [
67
"127.0.0.1",

0 commit comments

Comments
 (0)