Python django.conf.settings.DOMAIN Examples
The following are 30
code examples of django.conf.settings.DOMAIN().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
django.conf.settings
, or try the search function
.
Example #1
Source File: send_volunteer_registration_emails.py From donation-tracker with Apache License 2.0 | 6 votes |
def handle(self, *args, **options): super(Command, self).handle(*args, **options) self.message(str(options), 3) self.verbosity = options['verbosity'] dryRun = options['dry_run'] template = options['template'] volunteersFile = options['volunteers_list'] sender = options['sender'] event = options['event'] volunteers = volunteer.parse_volunteer_info_file(volunteersFile) volunteer.send_volunteer_mail( settings.DOMAIN, event, volunteers, template, sender, verbosity=self.verbosity, dry_run=dryRun, )
Example #2
Source File: test_bgwork.py From canvas with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_full_stack(self): path = Config['test_bgwork_path'] if os.path.isfile(path): os.remove(path) # Post a fact. resp = urllib2.urlopen('http://{}/api/testing/test_bgwork'.format(settings.DOMAIN)) # Look for the fact. TIMEOUT = 10 # s t = time.time() while True: time.sleep(.3) if os.path.isfile(Config['test_bgwork_path']): break if time.time() - t > TIMEOUT: raise Exception("test_bgwork flag file wasn't written.")
Example #3
Source File: util.py From canvas with BSD 3-Clause "New" or "Revised" License | 6 votes |
def make_absolute_url(relative_url, protocol=None): """ Takes a relative url and makes it absolute by prepending the Canvas absolute domain. This refers not to relative as in "foo" resolving to "/bar/foo" when you're already on "/bar", but to an absolute path sans the host portion of the URL. `protocol` should be the name without the "://", e.g. "http" or "https" """ # Is it already absolute? if relative_url.split('//')[-1].startswith(settings.DOMAIN) and relative_url.startswith(protocol or '//'): return relative_url if protocol: protocol = protocol + '://' else: protocol = '//' base = protocol + settings.DOMAIN return urljoin(base, relative_url)
Example #4
Source File: schema.py From cookiecutter-django-vue with BSD 3-Clause "New" or "Revised" License | 6 votes |
def mutate(self, info, email): try: user = User.objects.get(email=email) except User.DoesNotExist: errors = ['emailDoesNotExists'] return ResetPassword(success=False, errors=errors) params = { 'user': user, 'DOMAIN': settings.DOMAIN, } send_mail( subject='Password reset', message=render_to_string('mail/password_reset.txt', params), from_email=settings.DEFAULT_FROM_EMAIL, recipient_list=[email], ) return ResetPassword(success=True)
Example #5
Source File: view_guards.py From canvas with BSD 3-Clause "New" or "Revised" License | 5 votes |
def require_secure(request): if not settings.HTTPS_ENABLED: return if request.META.get('HTTP_X_FORWARDED_PROTO') != 'https': return HttpResponseRedirect('https://' + settings.DOMAIN + request.get_full_path())
Example #6
Source File: models.py From canvas with BSD 3-Clause "New" or "Revised" License | 5 votes |
def get_share_page_url(self, absolute=False): url = self.details().share_page_url if absolute: url = 'http://' + settings.DOMAIN + url return url
Example #7
Source File: models.py From canvas with BSD 3-Clause "New" or "Revised" License | 5 votes |
def absolute_share_page_url(self): return "https://{0}{1}".format(settings.DOMAIN, self.share_page_url)
Example #8
Source File: models.py From canvas with BSD 3-Clause "New" or "Revised" License | 5 votes |
def absolute_parent_url(self): if not self.parent_url: return None return "https://{0}{1}".format(settings.DOMAIN, self.parent_url)
Example #9
Source File: models.py From canvas with BSD 3-Clause "New" or "Revised" License | 5 votes |
def absolute_url(self): return "https://{0}{1}".format(settings.DOMAIN, self.url)
Example #10
Source File: models.py From canvas with BSD 3-Clause "New" or "Revised" License | 5 votes |
def api_url(self): return "https://{0}/public_api/posts/{1}".format(settings.DOMAIN, self.post_id())
Example #11
Source File: models.py From canvas with BSD 3-Clause "New" or "Revised" License | 5 votes |
def api_url(self): return "https://{0}/public/users/{1}".format(settings.DOMAIN, self.user)
Example #12
Source File: models.py From canvas with BSD 3-Clause "New" or "Revised" License | 5 votes |
def url(self): return "https://{0}/x/{1}".format(settings.DOMAIN, self.group)
Example #13
Source File: tests.py From canvas with BSD 3-Clause "New" or "Revised" License | 5 votes |
def check_comment(self, expected, json): self.assertEqual(short_id(expected.id), json['id']) self.assertEqual(expected.title, json['title']) self.assertEqual(expected.category, json['category']) self.assertEqual(expected.reply_text, json['caption']) self.assertEqual(expected.author_name, json['author_name']) self.assertEqual(expected.parent_comment, json['parent_comment']) self.assertEqual(expected.parent_url, json['parent_url']) self.assertEqual(short_id(expected.thread_op_comment_id), json['thread_op_id']) self.assertEqual("https://{0}".format(settings.DOMAIN) + expected.share_page_url, json['share_page_url']) self.assertEqual(expected.replied_comment, json['reply_to']) self.assertEqual(expected.top_sticker(), json['top_sticker']) self.assertEqual(int(expected.timestamp), json['timestamp']) self.assertEqual("https://{0}".format(settings.DOMAIN) + expected.url, json['url'])
Example #14
Source File: models.py From canvas with BSD 3-Clause "New" or "Revised" License | 5 votes |
def generate_homepage(): threads = spotlighted_threads() ctx = { 'threads': threads, 'DOMAIN': settings.DOMAIN, } return render_jinja_to_string('logged_out_homepage/homepage.html', ctx)
Example #15
Source File: models.py From canvas with BSD 3-Clause "New" or "Revised" License | 5 votes |
def absolute_url(self): return 'http://' + settings.DOMAIN + self.url
Example #16
Source File: sitemaps.py From canvas with BSD 3-Clause "New" or "Revised" License | 5 votes |
def get_urls(self, page=1, site=None): """ A hack so that we don't have to use django.sites """ urls = super(BaseSitemap, self).get_urls(page, site) if site.domain != settings.DOMAIN: for url in urls: url['location'] = url['location'].replace("http://"+site.domain, "", 1) return urls
Example #17
Source File: prize.py From donation-tracker with Apache License 2.0 | 5 votes |
def make_winner_url(self, domain=settings.DOMAIN): return ( domain + reverse('tracker:prize_winner', args=[self.pk]) + '?auth_code={0}'.format(self.auth_code) )
Example #18
Source File: test_util.py From canvas with BSD 3-Clause "New" or "Revised" License | 5 votes |
def tearDown(self): settings.DOMAIN = self._domain super(TestAbsoluteUrls, self).tearDown()
Example #19
Source File: test_util.py From canvas with BSD 3-Clause "New" or "Revised" License | 5 votes |
def setUp(self): super(TestAbsoluteUrls, self).setUp() self._domain, settings.DOMAIN = settings.DOMAIN, 'foo.com'
Example #20
Source File: utils.py From bennedetto with GNU General Public License v3.0 | 5 votes |
def expand_url_path(path, domain=None): domain = domain or settings.DOMAIN url = urljoin('//{}'.format(domain), path) return url[2:]
Example #21
Source File: prizemail.py From donation-tracker with Apache License 2.0 | 5 votes |
def automail_inactive_prize_handlers( event, inactiveUsers, mailTemplate, sender=None, replyTo=None, domain=settings.DOMAIN, verbosity=0, dry_run=False, ): sender, replyTo = event_sender_replyto_defaults(event, sender, replyTo) for inactiveUser in inactiveUsers: eventPrizes = list( Prize.objects.filter(handler=inactiveUser, event=event, state='ACCEPTED') ) formatContext = { 'event': event, 'handler': inactiveUser, 'register_url': domain + reverse('tracker:register'), 'prize_set': eventPrizes, 'prize_count': len(eventPrizes), 'reply_address': replyTo, } if not dry_run: post_office.mail.send( recipients=[inactiveUser.email], sender=sender, template=mailTemplate, context=formatContext, headers={'Reply-to': replyTo}, ) message = 'Mailed prize handler {0} (#{1}) for account activation'.format( inactiveUser, inactiveUser.id ) if verbosity > 0: print(message) if not dry_run: viewutil.tracker_log('prize', message, event)
Example #22
Source File: email_channel.py From canvas with BSD 3-Clause "New" or "Revised" License | 5 votes |
def make_thread_unsubscribe_link(self, comment, recipient): return string.Template("$absolute_path/unsubscribe?post=$post&token=$token&user_id=$user_id").substitute( dict(absolute_path="http://" + settings.DOMAIN, post=comment.thread.op.id, user_id=recipient.id, token=util.token(recipient.id)), )
Example #23
Source File: email_channel.py From canvas with BSD 3-Clause "New" or "Revised" License | 5 votes |
def make_action_unsubscribe_link(self, action, recipient): if settings.PROJECT == 'drawquest': #TODO individual action unsubscriptions: action instead of 'ALL' return '{}/unsubscribe?action={}&token={}&email={}'.format("http://" + settings.DOMAIN, 'ALL', util.token(recipient.email), recipient.email) else: return string.Template("$absolute_path/unsubscribe?action=$action&token=$token&user_id=$user_id").substitute( dict(absolute_path="http://" + settings.DOMAIN, action=action, user_id=recipient.id, token=util.token(recipient.id)), )
Example #24
Source File: email_channel.py From canvas with BSD 3-Clause "New" or "Revised" License | 5 votes |
def inline_the_styles(self): self.body_html = premailer.transform(self.raw_body_html, base_url="http://" + settings.DOMAIN + "/")
Example #25
Source File: processors.py From bennedetto with GNU General Public License v3.0 | 5 votes |
def constants(request): ''' injects certain constants form settings module into template context ''' return {'DEBUG': settings.DEBUG, 'DOMAIN': settings.DOMAIN, 'API_URL': settings.API_URL, 'STATIC_URL': settings.STATIC_URL, 'VERSION': settings.VERSION}
Example #26
Source File: utils.py From open-humans with MIT License | 5 votes |
def full_url(url_fragment): """ Given a fragment, return that fragment joined to the full Open Humans URL. """ if url_fragment and not url_fragment.startswith("/"): return url_fragment return urllib.parse.urljoin( settings.DEFAULT_HTTP_PROTOCOL + "://" + settings.DOMAIN, str(url_fragment) )
Example #27
Source File: middleware.py From canvas with BSD 3-Clause "New" or "Revised" License | 5 votes |
def process_request(self, request): def redirect_https(): return HttpResponseRedirect('https://' + settings.DOMAIN + request.get_full_path()) if not request.is_secure(): # Check for a secure_only cookie secure_only_cookie = request.COOKIES.get('secure_only', 'false').strip().lower() == 'true' # Check the user KV for the Force HTTPS setting. secure_only_kv = request.user.is_authenticated() and request.user.kv.secure_only.get() if secure_only_cookie or secure_only_kv: return redirect_https()
Example #28
Source File: models.py From Cinema with MIT License | 5 votes |
def item_link(self, item): return urllib.parse.urljoin(settings.DOMAIN, reverse('watch', kwargs={'mid': item.id}))
Example #29
Source File: models.py From Cinema with MIT License | 5 votes |
def item_description(self, item): if item.poster: return "<div><img src=\"{}\" style=\"width: 200px;\"/><p>{}</p></div>".format(urllib.parse.urljoin(settings.DOMAIN, item.poster.url), item.plot) return item.plot
Example #30
Source File: serializers.py From autoAdmin with GNU Lesser General Public License v3.0 | 5 votes |
def create(self, validated_data): validated_data["is_active"] = False instance = super(UserRegSerializer, self).create(validated_data=validated_data) instance.email = "{}{}".format(instance.username, settings.DOMAIN) instance.set_password(validated_data["password"]) instance.id_rsa_key, instance.id_rsa_pub = self.get_sshkey(instance.email) instance.save() return instance