Python django.conf.settings.SITE_NAME Examples

The following are 30 code examples for showing how to use django.conf.settings.SITE_NAME(). These examples are extracted from open source projects. 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 check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module django.conf.settings , or try the search function .

Example 1
Project: karrot-backend   Author: yunity   File: receivers.py    License: GNU Affero General Public License v3.0 6 votes vote down vote up
def notify_chat_on_group_creation(sender, instance, created, **kwargs):
    """Send notifications to admin chat"""
    if not created:
        return
    group = instance
    webhook_url = getattr(settings, 'ADMIN_CHAT_WEBHOOK', None)

    if webhook_url is None:
        return

    group_url = frontend_urls.group_preview_url(group)

    message_data = {
        'text': f':tada: A new group has been created on **{settings.SITE_NAME}**! [Visit {group.name}]({group_url})',
    }

    response = requests.post(webhook_url, data=json.dumps(message_data), headers={'Content-Type': 'application/json'})
    response.raise_for_status() 
Example 2
Project: online-judge   Author: DMOJ   File: two_factor.py    License: GNU Affero General Public License v3.0 6 votes vote down vote up
def get(self, request, *args, **kwargs):
        challenge = os.urandom(32)
        request.session['webauthn_attest'] = webauthn_encode(challenge)
        data = webauthn.WebAuthnMakeCredentialOptions(
            challenge=challenge,
            rp_id=settings.WEBAUTHN_RP_ID,
            rp_name=settings.SITE_NAME,
            user_id=request.profile.webauthn_id,
            username=request.user.username,
            display_name=request.user.username,
            user_verification='discouraged',
            icon_url=gravatar(request.user.email),
            attestation='none',
        ).registration_dict
        data['excludeCredentials'] = [{
            'type': 'public-key',
            'id': {'_bytes': credential.cred_id},
        } for credential in request.profile.webauthn_credentials.all()]
        return JsonResponse(data, encoder=WebAuthnJSONEncoder) 
Example 3
Project: healthchecks   Author: healthchecks   File: test_project.py    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def test_it_adds_team_member(self):
        self.client.login(username="alice@example.org", password="password")

        form = {"invite_team_member": "1", "email": "frank@example.org"}
        r = self.client.post(self.url, form)
        self.assertEqual(r.status_code, 200)

        members = self.project.member_set.all()
        self.assertEqual(members.count(), 2)

        member = Member.objects.get(
            project=self.project, user__email="frank@example.org"
        )

        # The new user should not have their own project
        self.assertFalse(member.user.project_set.exists())

        # And an email should have been sent
        subj = (
            "You have been invited to join"
            " Alice's Project on %s" % settings.SITE_NAME
        )
        self.assertHTMLEqual(mail.outbox[0].subject, subj) 
Example 4
Project: healthchecks   Author: healthchecks   File: test_profile.py    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def test_it_sends_set_password_link(self):
        self.client.login(username="alice@example.org", password="password")

        form = {"set_password": "1"}
        r = self.client.post("/accounts/profile/", form)
        assert r.status_code == 302

        # profile.token should be set now
        self.profile.refresh_from_db()
        token = self.profile.token
        self.assertTrue(len(token) > 10)

        # And an email should have been sent
        self.assertEqual(len(mail.outbox), 1)
        expected_subject = "Set password on %s" % settings.SITE_NAME
        self.assertEqual(mail.outbox[0].subject, expected_subject) 
Example 5
Project: healthchecks   Author: healthchecks   File: test_profile.py    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def test_it_sends_change_email_link(self):
        self.client.login(username="alice@example.org", password="password")

        form = {"change_email": "1"}
        r = self.client.post("/accounts/profile/", form)
        assert r.status_code == 302

        # profile.token should be set now
        self.profile.refresh_from_db()
        token = self.profile.token
        self.assertTrue(len(token) > 10)

        # And an email should have been sent
        self.assertEqual(len(mail.outbox), 1)
        expected_subject = "Change email address on %s" % settings.SITE_NAME
        self.assertEqual(mail.outbox[0].subject, expected_subject) 
Example 6
Project: healthchecks   Author: healthchecks   File: transports.py    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def notify(self, check):
        profile = Profile.objects.for_user(self.channel.project.owner)
        if not profile.authorize_sms():
            profile.send_sms_limit_notice("SMS")
            return "Monthly SMS limit exceeded"

        url = self.URL % settings.TWILIO_ACCOUNT
        auth = (settings.TWILIO_ACCOUNT, settings.TWILIO_AUTH)
        text = tmpl("sms_message.html", check=check, site_name=settings.SITE_NAME)

        data = {
            "From": settings.TWILIO_FROM,
            "To": self.channel.sms_number,
            "Body": text,
        }

        return self.post(url, data=data, auth=auth) 
Example 7
Project: Inboxen   Author: Inboxen   File: manifest.py    License: GNU Affero General Public License v3.0 6 votes vote down vote up
def manifest(request):
    data = {
        "name": settings.SITE_NAME,
        "short_name": settings.SITE_NAME,
        "icons": [
            {
                "src": static("imgs/megmelon-icon-white.png"),
                "sizes": "128x128",
                "type": "image/png"
            }
        ],
        "theme_color": "#ffffff",
        "background_color": "#ffffff",
        "display": "browser",
        "start_url": reverse("user-home"),
    }

    return JsonResponse(data) 
Example 8
Project: karrot-backend   Author: yunity   File: setup_sparkpost.py    License: GNU Affero General Public License v3.0 5 votes vote down vote up
def setup_event_webhook(self, s):
        response = s.get('https://api.sparkpost.com/api/v1/webhooks')
        self.log_response(response)
        if not status.is_success(response.status_code):
            self.errors.append(
                'Failed to get existing event webhooks.' +
                'Check if your subaccount API key has permission to Read/Write Event Webhooks.'
            )

        webhooks = response.json()
        event_webhook_data = {
            "name": settings.SITE_NAME[:23],  # obey sparkpost name length limit
            "target": settings.HOSTNAME + "/api/webhooks/email_event/",
            "auth_type": "basic",
            "auth_credentials": {
                "username": "xxx",
                "password": settings.SPARKPOST_WEBHOOK_SECRET
            },
            "events": settings.SPARKPOST_EMAIL_EVENTS,
        }
        existing_event_webhook = None
        for w in webhooks['results']:
            if w['target'] == event_webhook_data['target']:
                existing_event_webhook = w

        if existing_event_webhook is None:
            print(
                'WARNING: creating a new event webhook for {}. '
                'Please check on sparkpost.com if there are unused ones.'.format(event_webhook_data['target'])
            )
            response = s.post('https://api.sparkpost.com/api/v1/webhooks', json=event_webhook_data)
            self.log_response(response)
            if not status.is_success(response.status_code):
                self.errors.append('Failed to create new event webhook')
        else:
            response = s.put(
                'https://api.sparkpost.com/api/v1/webhooks/' + existing_event_webhook['id'], json=event_webhook_data
            )
            self.log_response(response)
            if not status.is_success(response.status_code):
                self.errors.append('Failed to update existing event webhook') 
Example 9
Project: karrot-backend   Author: yunity   File: test_api.py    License: GNU Affero General Public License v3.0 5 votes vote down vote up
def test_invite_with_different_invited_by_language(self):
        self.member.language = 'fr'
        self.member.save()
        self.client.force_login(self.member)
        response = self.client.post(base_url, {'email': 'please@join.com', 'group': self.group.id})
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
        expected = f'[{settings.SITE_NAME}] Invitation de joinde {self.group.name}'
        self.assertEqual(mail.outbox[-1].subject, expected) 
Example 10
Project: cadasta-platform   Author: Cadasta   File: mixins.py    License: GNU Affero General Public License v3.0 5 votes vote down vote up
def get_serializer_context(self, *args, **kwargs):
        context = super(OrganizationRoles, self).get_serializer_context(
            *args, **kwargs)
        context['organization'] = self.get_organization()
        context['domain'] = get_current_site(self.request).domain
        context['sitename'] = settings.SITE_NAME
        return context 
Example 11
def site_name(request):
    return {'SITE_NAME': settings.SITE_NAME,
            'SITE_LONG_NAME': settings.SITE_LONG_NAME,
            'SITE_ADMIN_EMAIL': settings.SITE_ADMIN_EMAIL} 
Example 12
Project: online-judge   Author: DMOJ   File: two_factor.py    License: GNU Affero General Public License v3.0 5 votes vote down vote up
def render_qr_code(cls, username, key):
        totp = pyotp.TOTP(key)
        uri = totp.provisioning_uri(username, settings.SITE_NAME)

        qr = qrcode.QRCode(box_size=1)
        qr.add_data(uri)
        qr.make(fit=True)

        image = qr.make_image(fill_color='black', back_color='white')
        buf = BytesIO()
        image.save(buf, format='PNG')
        return 'data:image/png;base64,' + base64.b64encode(buf.getvalue()).decode('ascii') 
Example 13
Project: lexpredict-contraxsuite   Author: LexPredict   File: set_site.py    License: GNU Affero General Public License v3.0 5 votes vote down vote up
def handle(self, *args, **options):
        Site.objects.update_or_create(
            id=settings.SITE_ID,
            defaults={
                'domain': settings.HOST_NAME,
                'name': settings.SITE_NAME
            }
        ) 
Example 14
Project: healthchecks   Author: healthchecks   File: test_login.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_it_sends_link(self):
        form = {"identity": "alice@example.org"}

        r = self.client.post("/accounts/login/", form)
        self.assertRedirects(r, "/accounts/login_link_sent/")

        # And email should have been sent
        self.assertEqual(len(mail.outbox), 1)
        subject = "Log in to %s" % settings.SITE_NAME
        self.assertEqual(mail.outbox[0].subject, subject) 
Example 15
Project: healthchecks   Author: healthchecks   File: test_signup.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_it_sends_link(self):
        form = {"identity": "alice@example.org"}

        r = self.client.post("/accounts/signup/", form)
        self.assertContains(r, "Account created")
        self.assertIn("auto-login", r.cookies)

        # An user should have been created
        user = User.objects.get()

        # And email sent
        self.assertEqual(len(mail.outbox), 1)
        subject = "Log in to %s" % settings.SITE_NAME
        self.assertEqual(mail.outbox[0].subject, subject)

        # A project should have been created
        project = Project.objects.get()
        self.assertEqual(project.owner, user)
        self.assertEqual(project.badge_key, user.username)

        # And check should be associated with the new user
        check = Check.objects.get()
        self.assertEqual(check.name, "My First Check")
        self.assertEqual(check.project, project)

        # A channel should have been created
        channel = Channel.objects.get()
        self.assertEqual(channel.project, project) 
Example 16
Project: healthchecks   Author: healthchecks   File: transports.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def notify(self, check):
        description = tmpl("pd_description.html", check=check)
        payload = {
            "service_key": self.channel.pd_service_key,
            "incident_key": str(check.code),
            "event_type": "trigger" if check.status == "down" else "resolve",
            "description": description,
            "client": settings.SITE_NAME,
            "client_url": check.details_url(),
        }

        return self.post(self.URL, json=payload) 
Example 17
Project: healthchecks   Author: healthchecks   File: transports.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def notify(self, check):
        url = self.channel.value
        headers = {"Conent-Type": "application/json"}
        payload = {
            "incident_key": str(check.code),
            "event_type": "trigger" if check.status == "down" else "resolve",
            "title": tmpl("pagertree_title.html", check=check),
            "description": tmpl("pagertree_description.html", check=check),
            "client": settings.SITE_NAME,
            "client_url": settings.SITE_ROOT,
            "tags": ",".join(check.tags_list()),
        }

        return self.post(url, json=payload, headers=headers) 
Example 18
Project: healthchecks   Author: healthchecks   File: transports.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def notify(self, check):
        text = tmpl("pushbullet_message.html", check=check)
        url = "https://api.pushbullet.com/v2/pushes"
        headers = {
            "Access-Token": self.channel.value,
            "Conent-Type": "application/json",
        }
        payload = {"type": "note", "title": settings.SITE_NAME, "body": text}

        return self.post(url, json=payload, headers=headers) 
Example 19
Project: healthchecks   Author: healthchecks   File: transports.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def notify(self, check):
        description = tmpl("victorops_description.html", check=check)
        mtype = "CRITICAL" if check.status == "down" else "RECOVERY"
        payload = {
            "entity_id": str(check.code),
            "message_type": mtype,
            "entity_display_name": check.name_then_code(),
            "state_message": description,
            "monitoring_tool": settings.SITE_NAME,
        }

        return self.post(self.channel.value, json=payload) 
Example 20
Project: healthchecks   Author: healthchecks   File: views.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def serve_doc(request, doc="introduction"):
    path = os.path.join(settings.BASE_DIR, "templates/docs", doc + ".html")
    if not os.path.exists(path):
        raise Http404("not found")

    replaces = {
        "{{ default_timeout }}": str(int(DEFAULT_TIMEOUT.total_seconds())),
        "{{ default_grace }}": str(int(DEFAULT_GRACE.total_seconds())),
        "SITE_NAME": settings.SITE_NAME,
        "SITE_ROOT": settings.SITE_ROOT,
        "SITE_HOSTNAME": site_hostname(),
        "SITE_SCHEME": site_scheme(),
        "PING_ENDPOINT": settings.PING_ENDPOINT,
        "PING_URL": settings.PING_ENDPOINT + "your-uuid-here",
        "IMG_URL": os.path.join(settings.STATIC_URL, "img/docs"),
    }

    content = open(path, "r", encoding="utf-8").read()
    for placeholder, value in replaces.items():
        content = content.replace(placeholder, value)

    ctx = {
        "page": "docs",
        "section": doc,
        "content": content,
        "first_line": content.split("\n")[0],
    }

    return render(request, "front/docs_single.html", ctx) 
Example 21
Project: healthchecks   Author: healthchecks   File: views.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def add_trello(request, code):
    project = _get_project_for_user(request, code)
    if request.method == "POST":
        channel = Channel(project=project, kind="trello")
        channel.value = request.POST["settings"]
        channel.save()

        channel.assign_all_checks()
        return redirect("hc-p-channels", project.code)

    return_url = settings.SITE_ROOT + reverse("hc-add-trello", args=[project.code])
    authorize_url = "https://trello.com/1/authorize?" + urlencode(
        {
            "expiration": "never",
            "name": settings.SITE_NAME,
            "scope": "read,write",
            "response_type": "token",
            "key": settings.TRELLO_APP_KEY,
            "return_url": return_url,
        }
    )

    ctx = {
        "page": "channels",
        "project": project,
        "authorize_url": authorize_url,
    }

    return render(request, "integrations/add_trello.html", ctx) 
Example 22
Project: healthchecks   Author: healthchecks   File: hc_extras.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def num_down_title(num_down):
    if num_down:
        return "%d down – %s" % (num_down, settings.SITE_NAME)
    else:
        return settings.SITE_NAME 
Example 23
Project: healthchecks   Author: healthchecks   File: hc_extras.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def down_title(check):
    """ Prepare title tag for the Details page.

    If the check is down, return "DOWN - Name - site_name".
    Otherwise, return "Name - site_name".

    """

    s = "%s – %s" % (check.name_then_code(), settings.SITE_NAME)
    if check.get_status() == "down":
        s = "DOWN – " + s

    return s 
Example 24
Project: pythonic-news   Author: sebst   File: mailing.py    License: GNU Affero General Public License v3.0 5 votes vote down vote up
def create_and_send_digest(frequency):
    pass
    # Get list of objects
    stories = [] # TODO: Find from _font_page
    # make templates and trigger sending
    subscriptions = Subscription.objects.filter(is_active=True, frequency=frequency)
    for subscription in subscriptions:
        tpl = 'TODO: Here is your list' # TODO
        subject = settings.SITE_NAME + " " + frequency + " Digest"
        send_mail(subscription, tpl, subject) 
Example 25
def settings_context_processor(request):
   return {
       'SITE_NAME': settings.SITE_NAME,
       'SITE_DOMAIN': settings.SITE_DOMAIN,
       'SITE_URL': settings.SITE_URL
   } 
Example 26
Project: django-leonardo   Author: django-leonardo   File: __init__.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def extra_context(self):
        """Add site_name to context
        """
        from django.conf import settings

        return {
            "site_name": (lambda r: settings.LEONARDO_SITE_NAME
                          if getattr(settings, 'LEONARDO_SITE_NAME', '') != ''
                          else settings.SITE_NAME),
            "debug": lambda r: settings.TEMPLATE_DEBUG
        } 
Example 27
Project: xblock-ooyala   Author: edx-solutions   File: ooyala_player.py    License: GNU Affero General Public License v3.0 5 votes vote down vote up
def local_resource_url(self, block, uri):
        """
        local_resource_url for xblocks, with lightchild support.
        """
        path = reverse('xblock_resource_url', kwargs={
            'block_type': block.lightchild_block_type or block.scope_ids.block_type,
            'uri': uri,
        })
        return '//{}{}'.format(settings.SITE_NAME, path) 
Example 28
Project: Bitpoll   Author: fsinfuhh   File: views.py    License: GNU General Public License v3.0 5 votes vote down vote up
def _verify_email(request, email):
    token = signing.dumps({
        'email': email,
        'username': request.user.username,
    })
    url_path = reverse('registration_change_email', args=(token,))
    link = request.build_absolute_uri(url_path)
    email_content = render_to_string('registration/email_verify.txt', {
        'username': request.user.username,
        'email': email,
        'link': link,
    })
    return _send_mail_or_error_page(_('Verify this address for %s' % settings.SITE_NAME),
                                    email_content, email, request) 
Example 29
Project: Bitpoll   Author: fsinfuhh   File: views.py    License: GNU General Public License v3.0 5 votes vote down vote up
def _finish_account_request(request, info):
    email = info['email']
    token = signing.dumps(info)
    url_path = reverse('registration_create_account', args=(token,))
    activation_link = request.build_absolute_uri(url_path)
    email_content = render_to_string('registration/create_email.txt', {
        'activation_link': activation_link
    })
    return _send_mail_or_error_page(_('Account creation at %s' % settings.SITE_NAME),
                                    email_content, email, request) 
Example 30
Project: protwis   Author: protwis   File: mainmenu.py    License: Apache License 2.0 5 votes vote down vote up
def mainmenu():
    return {
        'site_title': settings.SITE_TITLE,
        'menu_template': 'home/mainmenu_' + settings.SITE_NAME + '.html',
        'logo_path': 'home/logo/' + settings.SITE_NAME + '/main.png',
        'documentation_url': settings.DOCUMENTATION_URL,
    }