当前位置: 首页>>代码示例>>Python>>正文


Python settings.BASE_URL属性代码示例

本文整理汇总了Python中django.conf.settings.BASE_URL属性的典型用法代码示例。如果您正苦于以下问题:Python settings.BASE_URL属性的具体用法?Python settings.BASE_URL怎么用?Python settings.BASE_URL使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在django.conf.settings的用法示例。


在下文中一共展示了settings.BASE_URL属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: make_absolute_url

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import BASE_URL [as 别名]
def make_absolute_url(path, site_name=None):
    if re.match(r"^https?://", path):
        return path

    if site_name:
        config = site_config.by_hostname(site_name)
        if settings.BASE_URL:
            url_base = settings.BASE_URL
            path = add_params(path, {"_hostname": config.hostname})
        else:
            url_base = f"https://{config.hostname}"
    else:
        hostname = settings.SERVER_DOMAIN
        scheme = "http" if hostname.startswith("localhost") else "https"
        url_base = f"{scheme}://{hostname}"

    return parse.urljoin(url_base, path) 
开发者ID:codeforboston,项目名称:cornerwise,代码行数:19,代码来源:utils.py

示例2: post

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import BASE_URL [as 别名]
def post(self, request, *args, **kwargs):
        if request.is_ajax():
            group = self.get_object()
            user = UserProfile.objects.get(user__pk=self.request.POST.get('user')).user

            if user not in group.join_requests.all():
                return HttpResponseForbidden()

            group.join_requests.remove(user)
            push_notification([user], 'group_join_request_rejected',
                              {
                                  'group_name': group.name,
                                  'url': settings.BASE_URL + reverse('group_detail', args=(group.pk,)),
                              })

            return self.render_json_response({
                'member': user.pk,
            })

        # Only AJAX allowed
        return HttpResponseForbidden() 
开发者ID:astrobin,项目名称:astrobin,代码行数:23,代码来源:group_reject_join_request.py

示例3: imagerevision_post_save

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import BASE_URL [as 别名]
def imagerevision_post_save(sender, instance, created, **kwargs):
    if created and not instance.image.is_wip and not instance.skip_notifications:
        followers = [x.user for x in ToggleProperty.objects.filter(
            property_type="follow",
            content_type=ContentType.objects.get_for_model(User),
            object_id=instance.image.user.pk)]

        push_notification(followers, 'new_image_revision',
                          {
                              'object_url': settings.BASE_URL + instance.get_absolute_url(),
                              'originator': instance.image.user.userprofile.get_display_name(),
                          })

        add_story(instance.image.user,
                  verb='VERB_UPLOADED_REVISION',
                  action_object=instance,
                  target=instance.image) 
开发者ID:astrobin,项目名称:astrobin,代码行数:19,代码来源:signals.py

示例4: solution_post_save

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import BASE_URL [as 别名]
def solution_post_save(sender, instance, created, **kwargs):
    ct = instance.content_type

    try:
        target = ct.get_object_for_this_type(pk=instance.object_id)
    except ct.model_class().DoesNotExist:
        return

    if ct.model == 'image':
        user = target.user
    elif ct.model == 'imagerevision':
        user = target.image.user
    else:
        return

    if instance.status == Solver.FAILED:
        notification = 'image_not_solved'
    elif instance.status == Solver.SUCCESS:
        notification = 'image_solved'
    else:
        return

    push_notification([user], notification,
                      {'object_url': settings.BASE_URL + target.get_absolute_url()}) 
开发者ID:astrobin,项目名称:astrobin,代码行数:26,代码来源:signals.py

示例5: forum_topic_pre_save

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import BASE_URL [as 别名]
def forum_topic_pre_save(sender, instance, **kwargs):
    if not hasattr(instance.forum, 'group'):
        return

    try:
        topic = sender.objects.get(pk=instance.pk)
    except sender.DoesNotExist:
        pass
    else:
        if topic.on_moderation == True and instance.on_moderation == False:
            # This topic is being approved
            group = instance.forum.group
            push_notification(
                [x for x in group.members.all() if x != instance.user],
                'new_topic_in_group',
                {
                    'user': instance.user.userprofile.get_display_name(),
                    'url': settings.BASE_URL + instance.get_absolute_url(),
                    'group_url': reverse_url('group_detail', kwargs={'pk': group.pk}),
                    'group_name': group.name,
                    'topic_title': instance.name,
                },
            ) 
开发者ID:astrobin,项目名称:astrobin,代码行数:25,代码来源:signals.py

示例6: forum_topic_post_save

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import BASE_URL [as 别名]
def forum_topic_post_save(sender, instance, created, **kwargs):
    if created and hasattr(instance.forum, 'group'):
        group = instance.forum.group

        if instance.on_moderation:
            recipients = group.moderators.all()
        else:
            recipients = group.members.all()
        recipients = [x for x in recipients if x != instance.user]

        push_notification(
            recipients,
            'new_topic_in_group',
            {
                'user': instance.user.userprofile.get_display_name(),
                'url': settings.BASE_URL + instance.get_absolute_url(),
                'group_url': settings.BASE_URL + reverse_url('group_detail', kwargs={'pk': group.pk}),
                'group_name': group.name,
                'topic_title': instance.name,
            },
        ) 
开发者ID:astrobin,项目名称:astrobin,代码行数:23,代码来源:signals.py

示例7: approve

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import BASE_URL [as 别名]
def approve(self):
        app, created = App.objects.get_or_create(
            registrar=self.registrar, name=self.name,
            description=self.description)

        self.approved = True
        self.save()

        if created:
            push_notification(
                [self.registrar], 'api_key_request_approved',
                {'api_docs_url': settings.BASE_URL + '/help/api/',
                 'api_keys_url': settings.BASE_URL + '/users/%s/apikeys/' % self.registrar.username,
                 'key': app.key,
                 'secret': app.secret})
        else:
            app.active = True

        app.save() 
开发者ID:astrobin,项目名称:astrobin,代码行数:21,代码来源:models.py

示例8: send_email

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import BASE_URL [as 别名]
def send_email(self, email_type):
        from django.core.mail import send_mail
        from django.template.loader import render_to_string
        from django.conf import settings
        
        email_content = render_to_string(
            "billing/invoice_%s.txt" % email_type,
            context={
                "username":self.customer.user.username,
                "amount":self.amount_string(),
                "due_date":datetime.datetime.fromtimestamp(
                    self.customer.expiry_timestamp
                ).strftime('%B %-d'),
                "invoice_id":self.pk,
                "base_url":settings.BASE_URL
            }
        )
        
        result = send_mail(
            'Your Acacia Invoice',
            email_content,
            'noreply@tradeacacia.com',
            [self.customer.user.email],
            fail_silently=True
        )
        return result == 1 
开发者ID:AcaciaTrading,项目名称:acacia_main,代码行数:28,代码来源:models.py

示例9: generate_download_script

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import BASE_URL [as 别名]
def generate_download_script(dataset):
    access_token_url = urljoin(settings.BASE_URL, reverse('get_access_token'))
    dataset_url = urljoin(settings.BASE_URL, reverse('dataset-sounds',
        kwargs={"short_name": dataset.short_name}))

    tvars = {
        'access_token_url': access_token_url,
        'dataset_url': dataset_url,
        'get_code_url': settings.FS_CLIENT_ID
    }
    return render_to_string('datasets/download_script.py', tvars) 
开发者ID:MTG,项目名称:freesound-datasets,代码行数:13,代码来源:utils.py

示例10: generate_notifications_for_incident

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import BASE_URL [as 别名]
def generate_notifications_for_incident(incident):
        now = timezone.make_aware(datetime.now(), timezone.get_current_timezone())
        duty_officers = get_escalation_for_service(incident.service_key)

        current_time = now

        notifications = []

        for officer_index, duty_officer in enumerate(duty_officers):
            escalation_time = incident.service_key.escalate_after * (officer_index + 1)
            escalate_at = current_time + timedelta(minutes=escalation_time)

            methods = duty_officer.notification_methods.order_by('position').all()
            method_index = 0

            for method in methods:
                notification_time = incident.service_key.retry * method_index + incident.service_key.escalate_after * officer_index
                notify_at = current_time + timedelta(minutes=notification_time)
                if notify_at < escalate_at:
                    notification = ScheduledNotification()
                    notification.incident = incident
                    notification.user_to_notify = duty_officer
                    notification.notifier = method.method
                    notification.send_at = notify_at
                    uri = settings.BASE_URL + "/incidents/details/" + str(incident.id)
                    notification.message = "A Service is experiencing a problem: " + incident.incident_key + " " + incident.description + ". Handle at: " + uri + " Details: " + incident.details

                    notifications.append(notification)

                    print "Notify %s at %s with method: %s" % (duty_officer.username, notify_at, notification.notifier)
                else:
                    break
                method_index += 1

            # todo: error handling

        return notifications 
开发者ID:ustream,项目名称:openduty,代码行数:39,代码来源:helper.py

示例11: generate_notifications_for_user

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import BASE_URL [as 别名]
def generate_notifications_for_user(incident, user, delay=None, preparedmsg = None):

        now = timezone.make_aware(datetime.now(), timezone.get_current_timezone())
        current_time = now
        notifications = []
        methods = user.notification_methods.order_by('position').all()
        method_index = 0

        for method in methods:
            if delay is None:
                notification_time = incident.service_key.retry * method_index + incident.service_key.escalate_after
            else:
                notification_time = method_index * delay
            notify_at = current_time + timedelta(minutes=notification_time)
            notification = ScheduledNotification()
            notification.incident = incident
            notification.user_to_notify = user
            notification.notifier = method.method
            notification.send_at = notify_at
            if preparedmsg is None:
                uri = settings.BASE_URL + "/incidents/details/" + str(incident.id)
                notification.message = "A Service is experiencing a problem: " + incident.incident_key + " " + incident.description + ". Handle at: " + uri
            else:
                notification.message = preparedmsg
            notifications.append(notification)
            print "Notify %s at %s with method: %s" % (user.username, notify_at, notification.notifier)
            method_index += 1

        # todo: error handling
        return notifications 
开发者ID:ustream,项目名称:openduty,代码行数:32,代码来源:helper.py

示例12: daily_mail

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import BASE_URL [as 别名]
def daily_mail(force=False):
    if date.today() in holidays.France() and not force:
        return

    for caisse in Caisse.objects.filter(active=True):
        mrsrequests = caisse.mrsrequest_set.all().status('new').order_by(
            'creation_datetime')

        if not len(mrsrequests):
            continue

        context = dict(
            object_list=mrsrequests,
            BASE_URL=settings.BASE_URL,
            ADMIN_ROOT=crudlfap.site.views['home'].url,
        )

        Caller(
            callback='djcall.django.email_send',
            kwargs=dict(
                subject=template.loader.get_template(
                    'caisse/liquidation_daily_mail_title.txt',
                ).render(context).strip(),
                body=template.loader.get_template(
                    'caisse/liquidation_daily_mail_body.html',
                ).render(context).strip(),
                to=[caisse.liquidation_email],
                reply_to=[settings.DEFAULT_FROM_EMAIL],
                content_subtype='html'
            )
        ).spool('mail') 
开发者ID:betagouv,项目名称:mrs,代码行数:33,代码来源:models.py

示例13: password_reset

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import BASE_URL [as 别名]
def password_reset(self, caisse):
        created = not self.password
        password = secrets.token_urlsafe(16)
        self.set_password(password)
        self.save()
        password_email_template = template.loader.get_template(
            'mrsuser/user_password_email.txt',
        )
        # In case of super admins not linked to any caisse, reply_to heads
        # to settings.TEAM_EMAIL
        email = caisse.habilitation_email if caisse else None

        if email:
            reply_to = email
        else:
            reply_to = settings.TEAM_EMAIL
        Caller(
            callback='djcall.django.email_send',
            kwargs=dict(
                subject=(
                    '[MRS] Votre mot de passe'
                    if created else
                    '[MRS] Votre nouveau mot de passe'
                ),
                body=password_email_template.render(dict(
                    created=created,
                    user=self,
                    password=password,
                    BASE_URL=settings.BASE_URL,
                )),
                to=[self.email],
                reply_to=[reply_to],
            )
        ).spool('mail') 
开发者ID:betagouv,项目名称:mrs,代码行数:36,代码来源:models.py

示例14: post

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import BASE_URL [as 别名]
def post(self, request, *args, **kwargs):
        if self.object.status != self.object.STATUS_NEW:
            return http.HttpResponseBadRequest()

        self.object.status = self.object.STATUS_CANCELED
        self.object.status_datetime = datetime.now()
        self.object.save()

        self.object.logentries.create(
            action=MRSRequest.STATUS_CANCELED,
            comment='Annulation',
        )

        body = template.loader.get_template(
            'mrsrequest/cancelation_email.txt'
        ).render(dict(object=self.object, base_url=settings.BASE_URL)).strip()

        Caller(
            callback='djcall.django.email_send',
            kwargs=dict(
                subject=f'MRS: Annulation demande {self.object.display_id}',
                body=body.strip(),
                to=[self.object.insured.email],
                reply_to=[self.object.caisse.liquidation_email],
            )
        ).spool('mail')

        return generic.TemplateView.get(self, request, *args, **kwargs) 
开发者ID:betagouv,项目名称:mrs,代码行数:30,代码来源:views.py

示例15: __init__

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import BASE_URL [as 别名]
def __init__(self, obj, index):
        has_canonical = hasattr(obj, 'canonical_name') and obj.canonical_name
        self.name = obj.canonical_name if has_canonical else obj.name
        self.url = settings.BASE_URL + url_mapping[obj.__class__] + obj.str_id
        self.index = index 
开发者ID:wncc,项目名称:instiapp-api,代码行数:7,代码来源:views.py


注:本文中的django.conf.settings.BASE_URL属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。