Skip to content

Commit

Permalink
cleaned up references to settings.SITE_URL
Browse files Browse the repository at this point in the history
  • Loading branch information
jsayles committed Feb 20, 2020
1 parent 9983e81 commit 922affc
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 29 deletions.
2 changes: 1 addition & 1 deletion comlink/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ User.helper.by_email(email)
The URLs used for unsubscribing and moderating are also tied to the Nadine application.

### Important settings
The email footer links rely on *settings.SITE_PROTO* and *settings.SITE_DOMAIN* to be set.
The email footer links rely on *settings.SITE_NAME* and *settings.SITE_URL* to be set.

Mailgun functionality relies on *settings.MAILGUN_DOMAIN* and *settings.MAILGUN_API_KEY* to be set.
*settings.MAILGUN_VALIDATION_KEY* is optional if you want to use the v3 validation logic.
2 changes: 1 addition & 1 deletion comlink/mailgun.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def send_template(template, to, subject, context=None):
context = {}
context["to"] = to
context["site_name"] = settings.SITE_NAME
context["site_url"] = "%s://%s" % (settings.SITE_PROTO, settings.SITE_DOMAIN)
context["site_url"] = settings.SITE_URL

# Render our body text
body_text = render_to_string(template, context=context)
Expand Down
4 changes: 2 additions & 2 deletions comlink/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class MailingList(models.Model):
@property
def unsubscribe_url(self):
# TODO - Make this a link to unsubscribe from this mailing list
return settings.SITE_PROTO + "://" + settings.SITE_DOMAIN
return settings.SITE_URL

@property
def subscriber_addresses(self):
Expand Down Expand Up @@ -170,7 +170,7 @@ def is_moderated_subject(self):

@property
def public_url(self):
return settings.SITE_PROTO + "://" + settings.SITE_DOMAIN + reverse('comlink:mail', kwargs={'id': self.id})
return settings.SITE_URL + reverse('comlink:mail', kwargs={'id': self.id})

def get_user(self):
if not self.user:
Expand Down
4 changes: 2 additions & 2 deletions member/views/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ def bill_receipt(request, bill_id):
'bill': bill,
'today': localtime(now()),
'site_name': settings.SITE_NAME,
'site_url': settings.SITE_URL(),
'bill_url': settings.SITE_URL() + bill.get_absolute_url()
'site_url': settings.SITE_URL,
'bill_url': settings.SITE_URL + bill.get_absolute_url()
}
receipt_html = htmltext.render(pdf_context)
pdf_file = HTML(string=receipt_html, base_url=request.build_absolute_uri()).write_pdf()
Expand Down
6 changes: 3 additions & 3 deletions nadine/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def default_context():
return {
'today': localtime(now()),
'site_name': settings.SITE_NAME,
'site_url': settings.SITE_URL(),
'site_url': settings.SITE_URL,
}

def send_manual(user, message):
Expand Down Expand Up @@ -77,7 +77,7 @@ def send_verification(emailObj):
verif_key = emailObj.get_verif_key()
context_dict = {
'site_name': settings.SITE_NAME,
'site_url': settings.SITE_URL(),
'site_url': settings.SITE_URL,
'user': emailObj.user,
'verif_key': verif_key,
}
Expand Down Expand Up @@ -349,7 +349,7 @@ def render_templates(context, email_key):
# inject some specific context
context['today'] = localtime(now())
context['site_name'] = settings.SITE_NAME
context['site_url'] = settings.SITE_URL()
context['site_url'] = settings.SITE_URL

try:
text_template = get_template("email/%s.txt" % email_key)
Expand Down
14 changes: 5 additions & 9 deletions nadine/management/commands/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,10 @@ def setup_general(self):

# Site Information
self.prompt_for_value("Site Name", "SITE_NAME")
current_host = socket.gethostname().lower()
self.prompt_for_value("Site Domain", "SITE_DOMAIN", default=current_host)
protocol = "http"
print("Use SSL? (y, N)")
ssl = input(PROMPT).strip().lower()
if ssl == "y":
protocol = protocol + "s"
self.local_settings.set('SITE_PROTO', protocol)
self.prompt_for_value("Site Url", "SITE_URL")
url = self.local_settings.get_value("SITE_URL")
if url.endswith("/"):
self.local_settings.set(SITE_URL, url[:-1])

# Site Administrator
print("Full Name of Administrator")
Expand Down Expand Up @@ -147,7 +143,7 @@ def setup_database(self):
def setup_email(self):
print()
print("### Email Setup ###")
domain = self.local_settings.get_value("SITE_DOMAIN")
domain = self.local_settings.get_value("SITE_URL").split('://')[1].split(':')[0].split('/')[0]
self.prompt_for_value("Email Host", "EMAIL_HOST")
self.prompt_for_value("Email Host User", "EMAIL_HOST_USER", default="postmaster@" + domain)
self.prompt_for_value("Email Host Password", "EMAIL_HOST_PASSWORD")
Expand Down
2 changes: 1 addition & 1 deletion nadine/models/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ def get_verify_link(self):
if not verify_link:
verif_key = self.get_verif_key()
uri = reverse('email_verify', kwargs={'email_pk': self.id}) + "?verif_key=" + verif_key
verify_link = settings.SITE_URL() + uri
verify_link = settings.SITE_URL + uri
return verify_link

def get_send_verif_link(self):
Expand Down
6 changes: 1 addition & 5 deletions nadine/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,7 @@
################################################################################

SITE_NAME = "Nadine"
SITE_DOMAIN = "localhost"
SITE_PROTO = "http"

def SITE_URL():
return SITE_PROTO + "://" + SITE_DOMAIN
SITE_URL = "http://nadine.example.com"


# Local time zone for this installation. Choices can be found here:
Expand Down
3 changes: 1 addition & 2 deletions nadine/settings/local_settings.example.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@

# Site Information
SITE_NAME = "Nadine"
SITE_DOMAIN = "127.0.0.1:8080"
SITE_PROTO = "http"
SITE_URL = "http://127.0.0.1:8080"
COUNTRY = "US"
TIME_ZONE = 'UTC'

Expand Down
2 changes: 1 addition & 1 deletion staff/views/payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def usaepay_user(request, username):
'user': user,
'history': history,
'site_name':settings.SITE_NAME,
'site_url':settings.SITE_URL(),
'site_url':settings.SITE_URL,
}
return render(request, 'staff/billing/usaepay.html', context)

Expand Down
2 changes: 1 addition & 1 deletion staff/views/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def index(request):
ip = network.get_addr(request)
context = {
'settings': settings,
'site_url': settings.SITE_URL(),
'site_url': settings.SITE_URL,
'ip': ip,
'request': request
}
Expand Down
2 changes: 1 addition & 1 deletion views.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def password_reset(request, is_admin_site=False, template_name='registration/pas
context = {
'form': form,
'site_name': settings.SITE_NAME,
'site_url': settings.SITE_URL(),
'site_url': settings.SITE_URL,
}
return render(request, template_name, context)

Expand Down

0 comments on commit 922affc

Please sign in to comment.