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


Python SiteConfiguration.get_solo方法代码示例

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


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

示例1: test_cleanup_expiry_date

# 需要导入模块: from site_config.models import SiteConfiguration [as 别名]
# 或者: from site_config.models.SiteConfiguration import get_solo [as 别名]
 def test_cleanup_expiry_date(self):
     config = SiteConfiguration.get_solo()
     config.sms_expiration_date = None
     config.save()
     logs.check_incoming_log()
     logs.check_outgoing_log()
     num_sms = models.SmsInbound.objects.count() + models.SmsOutbound.objects.count()
     logs.cleanup_expired_sms()
     assert num_sms > 0
     assert models.SmsInbound.objects.count() + models.SmsOutbound.objects.count() == num_sms
     config = SiteConfiguration.get_solo()
     config.sms_expiration_date = today + timedelta(days=1)
     config.save()
     logs.cleanup_expired_sms()
     assert models.SmsInbound.objects.count() + models.SmsOutbound.objects.count() == 0
开发者ID:nikolay,项目名称:apostello,代码行数:17,代码来源:test_logs.py

示例2: test_cleanup_expired_sms

# 需要导入模块: from site_config.models import SiteConfiguration [as 别名]
# 或者: from site_config.models.SiteConfiguration import get_solo [as 别名]
 def test_cleanup_expired_sms(self, smsin):
     config = SiteConfiguration.get_solo()
     config.sms_expiration_date = None
     config.save()
     for sms in SmsInbound.objects.all():
         # move back in time so they can be deleted
         sms.time_received = sms.time_received - timedelta(days=5)
         sms.save()
     cleanup_expired_sms()
     assert SmsInbound.objects.count() == len(smsin)
     config = SiteConfiguration.get_solo()
     config.sms_expiration_date = timezone.localdate()
     config.save()
     cleanup_expired_sms()
     assert SmsInbound.objects.count() == 0
开发者ID:nikolay,项目名称:apostello,代码行数:17,代码来源:test_tasks.py

示例3: global_settings

# 需要导入模块: from site_config.models import SiteConfiguration [as 别名]
# 或者: from site_config.models.SiteConfiguration import get_solo [as 别名]
def global_settings(request):
    """Expose TWILIO_FROM_NUM, DEBUG and site config in templates."""
    return {
        'CONFIG': SiteConfiguration.get_solo(),
        'DISPLAY_GOOGLE_LOGIN': SocialApp.objects.filter(provider='google').count(),
        'ROLLBAR_ACCESS_TOKEN_CLIENT': settings.ROLLBAR_ACCESS_TOKEN_CLIENT,
    }
开发者ID:nikolay,项目名称:apostello,代码行数:9,代码来源:context_processors.py

示例4: fetch_elvanto_groups

# 需要导入模块: from site_config.models import SiteConfiguration [as 别名]
# 或者: from site_config.models.SiteConfiguration import get_solo [as 别名]
def fetch_elvanto_groups(force=False):
    """Fetch all Elvanto groups."""
    from site_config.models import SiteConfiguration
    config = SiteConfiguration.get_solo()
    if force or config.sync_elvanto:
        from elvanto.models import ElvantoGroup
        ElvantoGroup.fetch_all_groups()
开发者ID:nikolay,项目名称:apostello,代码行数:9,代码来源:tasks.py

示例5: pull_elvanto_groups

# 需要导入模块: from site_config.models import SiteConfiguration [as 别名]
# 或者: from site_config.models.SiteConfiguration import get_solo [as 别名]
def pull_elvanto_groups(force=False):
    """Pull all the Elvanto groups that are set to sync."""
    from site_config.models import SiteConfiguration
    config = SiteConfiguration.get_solo()
    if force or config.sync_elvanto:
        from elvanto.models import ElvantoGroup
        ElvantoGroup.pull_all_groups()
开发者ID:nikolay,项目名称:apostello,代码行数:9,代码来源:tasks.py

示例6: get_person_or_ask_for_name

# 需要导入模块: from site_config.models import SiteConfiguration [as 别名]
# 或者: from site_config.models.SiteConfiguration import get_solo [as 别名]
def get_person_or_ask_for_name(from_, sms_body, keyword_obj):
    """
    Return the Recipient object for the sender of the message.

    Perform a look up on the sender of the message.
    If they exist in the system, they are returned.
    Otherwise a message is queued to ask them for their name.
    """
    try:
        person_from = Recipient.objects.get(number=from_)
    except Recipient.DoesNotExist:
        person_from = Recipient.objects.create(
            number=from_,
            first_name='Unknown',
            last_name='Person'
        )
        person_from.save()
        if keyword_obj == "name":
            pass
        else:
            from site_config.models import SiteConfiguration
            config = SiteConfiguration.get_solo()
            if not config.disable_all_replies:
                person_from.send_message(
                    content=fetch_default_reply('auto_name_request'),
                    sent_by="auto name request"
                )
                notify_office_mail.delay(
                    '[Apostello] Unknown Contact!',
                    'SMS: {0}\nFrom: {1}\n\n\nThis person is unknown and has been asked for their name.'.format(
                        sms_body, from_
                    ),
                )

    return person_from
开发者ID:gitter-badger,项目名称:apostello,代码行数:37,代码来源:reply.py

示例7: recipient_send_message_task

# 需要导入模块: from site_config.models import SiteConfiguration [as 别名]
# 或者: from site_config.models.SiteConfiguration import get_solo [as 别名]
def recipient_send_message_task(recipient_pk, body, group, sent_by):
    """Send a message asynchronously."""
    from apostello.models import Recipient
    from site_config.models import SiteConfiguration
    recipient = Recipient.objects.get(pk=recipient_pk)
    if recipient.is_archived:
        # if recipient is not active, fail silently
        return

    from apostello.models import SmsOutbound, RecipientGroup
    # if %name% is present, replace:
    body = recipient.personalise(body)
    # send twilio message
    try:
        message = get_twilio_client().messages.create(
            body=body, to=str(recipient.number), from_=str(SiteConfiguration.get_solo().twilio_from_num)
        )
        # add to sms out table
        sms = SmsOutbound(sid=message.sid, content=body, time_sent=timezone.now(), recipient=recipient, sent_by=sent_by)
        if group is not None:
            sms.recipient_group = RecipientGroup.objects.filter(name=group)[0]
        sms.save()
    except TwilioRestException as e:
        if e.code == 21610:
            recipient.is_blocking = True
            recipient.save()
            async('apostello.tasks.blacklist_notify', recipient.pk, '', 'stop')
        else:
            raise e
开发者ID:nikolay,项目名称:apostello,代码行数:31,代码来源:tasks.py

示例8: test_import_outgoing_rolling

# 需要导入模块: from site_config.models import SiteConfiguration [as 别名]
# 或者: from site_config.models.SiteConfiguration import get_solo [as 别名]
 def test_import_outgoing_rolling(self):
     config = SiteConfiguration.get_solo()
     config.sms_expiration_date = None
     config.sms_rolling_expiration_days = 0
     config.save()
     logs.check_outgoing_log()
     assert models.SmsOutbound.objects.filter(time_sent__lt=today).count() == 0
开发者ID:nikolay,项目名称:apostello,代码行数:9,代码来源:test_logs.py

示例9: send_async_mail

# 需要导入模块: from site_config.models import SiteConfiguration [as 别名]
# 或者: from site_config.models.SiteConfiguration import get_solo [as 别名]
def send_async_mail(subject, body, to):
    """Send email."""
    # read email settings from DB
    from site_config.models import SiteConfiguration
    s = SiteConfiguration.get_solo()
    from_ = s.email_from
    send_mail(subject, body, from_, to)
开发者ID:nikolay,项目名称:apostello,代码行数:9,代码来源:tasks.py

示例10: test_cleanup

# 需要导入模块: from site_config.models import SiteConfiguration [as 别名]
# 或者: from site_config.models.SiteConfiguration import get_solo [as 别名]
 def test_cleanup(self):
     # setup
     config = SiteConfiguration.get_solo()
     config.sms_rolling_expiration_days = None
     config.sms_expiration_date = today - timedelta(days=100)
     config.save()
     sms = models.SmsInbound.objects.create(
         content='test message',
         time_received=timezone.now() - timedelta(50),
         sender_name="John Calvin",
         sender_num="+447927401749",
         matched_keyword="test",
         sid='12345'
     )
     sms.save()
     assert models.SmsInbound.objects.count() == 1  # we have one sms
     logs.cleanup_expired_sms()
     assert models.SmsInbound.objects.count() == 1  # cleanup should leave it untouched
     config.sms_rolling_expiration_days = 50
     config.save()
     logs.cleanup_expired_sms()
     assert models.SmsInbound.objects.count() == 1  # cleanup should leave it untouched
     config.sms_rolling_expiration_days = 49
     config.save()
     logs.cleanup_expired_sms()
     assert models.SmsInbound.objects.count() == 0  # cleanup should remove sms
开发者ID:nikolay,项目名称:apostello,代码行数:28,代码来源:test_logs.py

示例11: elm_settings

# 需要导入模块: from site_config.models import SiteConfiguration [as 别名]
# 或者: from site_config.models.SiteConfiguration import get_solo [as 别名]
def elm_settings(user):
    try:
        profile = user.profile
    except AttributeError:
        profile = UserProfile.nullProfile()

    config = SiteConfiguration.get_solo()
    try:
        twilio_settings = config.get_twilio_settings()
        # remove sensitive settings:
        del twilio_settings['auth_token']
        del twilio_settings['sid']
    except ConfigurationError:
        twilio_settings = None

    bk_key = f'blocked_keywords_user_{user.pk}'
    blocked_keywords = cache.get(bk_key)
    if blocked_keywords is None:
        blocked_keywords = [
            x.keyword for x in Keyword.objects.all().prefetch_related('owners') if not x.can_user_access(user)
        ]
        cache.set(bk_key, blocked_keywords, 120)

    elm = {
        'userPerms': UserProfileSerializer(profile).data,
        'twilio': twilio_settings,
        'isEmailSetup': config.is_email_setup(),
        'smsCharLimit': config.sms_char_limit,
        'defaultNumberPrefix': config.default_number_prefix,
        'noAccessMessage': config.not_approved_msg,
        'blockedKeywords': blocked_keywords,
    }
    return mark_safe(json.dumps(elm))
开发者ID:nikolay,项目名称:apostello,代码行数:35,代码来源:apostello_extras.py

示例12: __init__

# 需要导入模块: from site_config.models import SiteConfiguration [as 别名]
# 或者: from site_config.models.SiteConfiguration import get_solo [as 别名]
 def __init__(self, *args, **kwargs):
     super(ApostelloEmailBackend, self).__init__(*args, **kwargs)
     from site_config.models import SiteConfiguration
     s = SiteConfiguration.get_solo()
     self.host = s.email_host
     self.port = s.email_port
     self.username = s.email_username
     self.password = s.email_password
开发者ID:nikolay,项目名称:apostello,代码行数:10,代码来源:mail.py

示例13: send_async_mail

# 需要导入模块: from site_config.models import SiteConfiguration [as 别名]
# 或者: from site_config.models.SiteConfiguration import get_solo [as 别名]
def send_async_mail(subject, body, to):
    """Send email."""
    # read email settings from DB, if they are empty, they will be read from
    # settings.py instead
    from site_config.models import SiteConfiguration
    s = SiteConfiguration.get_solo()
    from_ = s.email_from or settings.EMAIL_FROM
    send_mail(subject, body, from_, to)
开发者ID:mrphishxxx,项目名称:apostello,代码行数:10,代码来源:tasks.py

示例14: global_settings

# 需要导入模块: from site_config.models import SiteConfiguration [as 别名]
# 或者: from site_config.models.SiteConfiguration import get_solo [as 别名]
def global_settings(request):
    """Expose TWILIO_FROM_NUM, DEBUG and site config in templates."""
    return {
        'TWILIO_FROM_NUM': settings.TWILIO_FROM_NUM,
        'TWILIO_SENDING_COST': settings.TWILIO_SENDING_COST,
        'DEBUG': settings.DEBUG,
        'CONFIG': SiteConfiguration.get_solo(),
    }
开发者ID:gitter-badger,项目名称:apostello,代码行数:10,代码来源:context_processors.py

示例15: test_no_name_raises

# 需要导入模块: from site_config.models import SiteConfiguration [as 别名]
# 或者: from site_config.models.SiteConfiguration import get_solo [as 别名]
 def test_no_name_raises(self):
     """Test shorter limit imposed with %name% present."""
     s = SiteConfiguration.get_solo()
     with pytest.raises(ValidationError):
         less_than_sms_char_limit(
             't %name%' *
             (s.sms_char_limit - settings.MAX_NAME_LENGTH + len('%name%'))
         )
开发者ID:monty5811,项目名称:apostello,代码行数:10,代码来源:test_validators.py


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