Python django.conf.settings.SITE_NAME Examples

The following are 30 code examples of django.conf.settings.SITE_NAME(). 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: receivers.py    From karrot-backend with 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
Source File: transports.py    From healthchecks with 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 #3
Source File: manifest.py    From Inboxen with 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 #4
Source File: two_factor.py    From online-judge with 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 #5
Source File: test_project.py    From healthchecks with 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 #6
Source File: test_profile.py    From healthchecks with 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 #7
Source File: test_profile.py    From healthchecks with 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 #8
Source File: mailing.py    From pythonic-news with 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 #9
Source File: views.py    From healthchecks with 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 #10
Source File: context_processors.py    From pythonic-news with GNU Affero General Public License v3.0 5 votes vote down vote up
def settings_context_processor(request):
   return {
       'SITE_NAME': settings.SITE_NAME,
       'SITE_DOMAIN': settings.SITE_DOMAIN,
       'SITE_URL': settings.SITE_URL
   } 
Example #11
Source File: __init__.py    From django-leonardo with 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 #12
Source File: ooyala_player.py    From xblock-ooyala with 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 #13
Source File: views.py    From Bitpoll with 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 #14
Source File: views.py    From Bitpoll with 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 #15
Source File: mainmenu.py    From protwis with 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,
    } 
Example #16
Source File: views.py    From django_blog with MIT License 5 votes vote down vote up
def global_setting(request):
    return {'SITE_NAME': settings.SITE_NAME, 'SITE_DESCP': settings.SITE_DESCP, 'SITE_KEYWORDS': settings.SITE_KEYWORDS} 
Example #17
Source File: load_initial_data.py    From madewithwagtail with MIT License 5 votes vote down vote up
def handle(self, *args, **options):
        fixtures_dir = os.path.join(settings.PROJECT_ROOT, settings.SITE_NAME, 'core', 'fixtures')
        fixture_file = os.path.join(fixtures_dir, 'initial_data.json')
        image_src_dir = os.path.join(fixtures_dir, 'images')
        image_dest_dir = os.path.join(settings.MEDIA_ROOT, 'original_images')

        call_command('loaddata', fixture_file, verbosity=3)

        if not os.path.isdir(image_dest_dir):
            os.makedirs(image_dest_dir)

        for filename in os.listdir(image_src_dir):
            shutil.copy(os.path.join(image_src_dir, filename), image_dest_dir) 
Example #18
Source File: tasks.py    From Inboxen with GNU Affero General Public License v3.0 5 votes vote down vote up
def new_question_notification(question_id):
    from inboxen.tickets.models import Question

    question = Question.objects.select_related("author").get(id=question_id)
    subject = SUBJECT_TMPL.format(site_name=settings.SITE_NAME, subject=question.subject, id=question.id)
    body = BODY_TMPL.format(user=question.author, subject=question.subject, body=question.body)

    try:
        mail_admins(subject, body)
        log.info("Sent admin email for Question: %s", question.pk)
    except Exception as exc:
        raise new_question_notification.retry(countdown=300, exc=exc) 
Example #19
Source File: views.py    From Inboxen with GNU Affero General Public License v3.0 5 votes vote down vote up
def description(self):
        return _("The latest news and updates for {0}").format(settings.SITE_NAME) 
Example #20
Source File: test_home.py    From Inboxen with GNU Affero General Public License v3.0 5 votes vote down vote up
def test_context(self):
        response = self.client.get(self.get_url())
        context_settings = response.context['settings']

        # test that something is getting set
        self.assertEqual(dj_settings.SITE_NAME, context_settings["SITE_NAME"])

        # test that INBOXEN_COMMIT_ID is actually working
        self.assertEqual(context_settings["INBOXEN_COMMIT_ID"], inboxen.__version__)

        # Please add any settings that may contain passwords or secrets:
        self.assertNotIn("SECRET_KEY", context_settings)
        self.assertNotIn("DATABASES", context_settings) 
Example #21
Source File: context_processors.py    From Inboxen with GNU Affero General Public License v3.0 5 votes vote down vote up
def reduced_settings_context(request):
    """Introduces a reduced set of settings into the context

    This allows access to settings which will often be used
    by the templates but exclude sensative information to such
    as the salt to prevent accidents or bugs in the rest of django
    compromising us.
    """
    reduced_settings = {
        "SITE_NAME": settings.SITE_NAME,
        "ENABLE_REGISTRATION": settings.ENABLE_REGISTRATION,
        "INBOXEN_COMMIT_ID": inboxen.__version__,
        "SOURCE_LINK": settings.SOURCE_LINK,
    }
    return {"settings": reduced_settings} 
Example #22
Source File: context_processors.py    From allianceauth with GNU General Public License v2.0 5 votes vote down vote up
def auth_settings(request):
    return {
        'SITE_NAME': settings.SITE_NAME,
        'NIGHT_MODE': NightModeRedirectView.night_mode_state(request),
    } 
Example #23
Source File: hc_extras.py    From healthchecks with 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 #24
Source File: setup_sparkpost.py    From karrot-backend with 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 #25
Source File: test_api.py    From karrot-backend with 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 #26
Source File: mixins.py    From cadasta-platform with 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 #27
Source File: template_context.py    From online-judge with GNU Affero General Public License v3.0 5 votes vote down vote up
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 #28
Source File: two_factor.py    From online-judge with 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 #29
Source File: set_site.py    From lexpredict-contraxsuite with 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 #30
Source File: test_login.py    From healthchecks with 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)