• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python utils.get_setting函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tendenci.apps.site_settings.utils.get_setting函数的典型用法代码示例。如果您正苦于以下问题:Python get_setting函数的具体用法?Python get_setting怎么用?Python get_setting使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: get_keywords

    def get_keywords(self):
        object = self.object

        ### Assign variables -----------------------
        dynamic_keywords = generate_meta_keywords(object.body)
        geo_location = get_setting('site','global','sitegeographiclocation')
        site_name = get_setting('site','global','sitedisplayname')


        ### Build string -----------------------
        value = ''

        list = [
            'Photos',
            geo_location,
            site_name,
        ]

        # remove blank items
        for item in list:
            if not item.strip():
                list.remove(item)

        value = '%s %s, %s' % (value, ', '.join(list), dynamic_keywords)


        return value
开发者ID:BIGGANI,项目名称:tendenci,代码行数:27,代码来源:module_meta.py


示例2: prepare_paypal_form

def prepare_paypal_form(request, payment):
    amount = "%.2f" % payment.amount
    image_url = get_setting('site', 'global', 'merchantlogo')
    site_url = get_setting('site', 'global', 'siteurl')
    notify_url = '%s%s' % (site_url, reverse('paypal.ipn'))
    currency_code = get_setting('site', 'global', 'currency')
    if not currency_code:
        currency_code = 'USD'
    params = {
              'business': settings.PAYPAL_MERCHANT_LOGIN,
              'image_url': image_url,
              'amount': amount,
              'notify_url': notify_url,
              'currency_code': currency_code,
              'invoice': payment.id,
              'item_name': payment.description,
              'first_name': payment.first_name,
              'last_name': payment.last_name,
              'email': payment.email,
              'address1': payment.address,
              'address2': payment.address2,
              'city': payment.city,
              'state': payment.state,
              'country': payment.country,
              'zip': payment.zip,
              'night_phone_a': payment.phone,
        }
    form = PayPalPaymentForm(initial=params)
    form.fields['return'] = forms.CharField(max_length=100,
                            widget=forms.HiddenInput,
                            initial=payment.response_page)

    return form
开发者ID:goetzk,项目名称:tendenci,代码行数:33,代码来源:utils.py


示例3: get_description

    def get_description(self):
        object = self.object

        ### Assign variables -----------------------
        site_name = get_setting('site','global','sitedisplayname')
        geo_location = get_setting('site','global','sitegeographiclocation')

        if object.description:
            content = object.description

        content = strip_tags(content) #strips HTML tags
        content = unescape_entities(content)
        content = content.replace("\n","").replace("\r","")
        content = truncate_words(content, 50) # ~ about 250 chars

        ### Build string -----------------------
        value = object.name

        value = '%s : %s' % (value, content)

        value = '%s Photo Sets for %s, %s' % (
            value, site_name, geo_location)

        value = value.strip()

        return value
开发者ID:BIGGANI,项目名称:tendenci,代码行数:26,代码来源:module_meta.py


示例4: save

    def save(self, *args, **kwargs):
        if not self.id:
            self.guid = str(uuid.uuid1())

        # match allow_anonymous_view with opposite of hide_in_search
        if self.hide_in_search:
            self.allow_anonymous_view = False
        else:
            self.allow_anonymous_view = get_setting('module', 'users', 'allowanonymoususersearchuser')
            
        self.allow_user_view =  get_setting('module', 'users', 'allowusersearch')
        if get_setting('module', 'memberships', 'memberprotection') == 'private':
            self.allow_member_view = False
        else:
            self.allow_member_view = True
        

        super(Profile, self).save(*args, **kwargs)

        try:
            from tendenci.apps.campaign_monitor.utils import update_subscription
            if hasattr(self, 'old_email') and getattr(self, 'old_email') != self.user.email:
                update_subscription(self, self.old_email)
                del self.old_email
        except ImportError:
            pass
开发者ID:RMUCapstone-MIS590,项目名称:tendenci,代码行数:26,代码来源:models.py


示例5: __init__

 def __init__(self, user, *args, **kwargs):
     super(MakePaymentForm, self).__init__(*args, **kwargs)
     self.initial['country'] = get_setting('site', 'global', 'defaultcountry')
     self.fields['reference_number'].label = get_setting('module',
                                                         'make_payment',
                                                         'referencenumberlabel') or _('Reference #')
     # populate the user fields
     if user and user.id:
         if 'captcha' in self.fields:
             self.fields.pop('captcha')
         self.fields['first_name'].initial = user.first_name
         self.fields['last_name'].initial = user.last_name
         self.fields['email'].initial = user.email
         try:
             profile = user.profile
             if profile:
                 self.fields['company'].initial = profile.company
                 self.fields['address'].initial = profile.address
                 self.fields['address2'].initial = profile.address2
                 self.fields['city'].initial = profile.city
                 self.fields['state'].initial = profile.state
                 self.fields['zip_code'].initial = profile.zipcode
                 self.fields['country'].initial = profile.country
                 self.fields['phone'].initial = profile.phone
         except:
             pass
开发者ID:tendenci,项目名称:tendenci,代码行数:26,代码来源:forms.py


示例6: prepare_paypal_form

def prepare_paypal_form(request, payment):
    amount = "%.2f" % payment.amount
    image_url = get_setting("site", "global", "MerchantLogo")
    site_url = get_setting("site", "global", "siteurl")
    notify_url = "%s/%s" % (site_url, reverse("paypal.ipn"))
    currency_code = get_setting("site", "global", "currency")
    if not currency_code:
        currency_code = "USD"
    params = {
        "business": settings.PAYPAL_MERCHANT_LOGIN,
        "image_url": image_url,
        "amount": amount,
        "notify_url": notify_url,
        "currency_code": currency_code,
        "invoice": payment.id,
        "item_name": payment.description,
        "first_name": payment.first_name,
        "last_name": payment.last_name,
        "email": payment.email,
        "address1": payment.address,
        "address2": payment.address2,
        "city": payment.city,
        "state": payment.state,
        "country": payment.country,
        "zip": payment.zip,
        "night_phone_a": payment.phone,
    }
    form = PayPalPaymentForm(initial=params)
    form.fields["return"] = forms.CharField(max_length=100, widget=forms.HiddenInput, initial=payment.response_page)

    return form
开发者ID:ZHW123,项目名称:tendenci,代码行数:31,代码来源:utils.py


示例7: __init__

    def __init__(self, *args, **kwargs):
        super(ModelSearchForm, self).__init__(*args, **kwargs)

        # Check to see if users should be included in global search
        include_users = False

        if kwargs['user'].profile.is_superuser or get_setting('module', 'users', 'allowanonymoususersearchuser') \
        or (kwargs['user'].is_authenticated() and get_setting('module', 'users', 'allowusersearch')):
            include_users = True

        if include_users:
            for app in registered_apps:
                if app['verbose_name'].lower() == 'user':
                    registered_apps_models.append(app['model'])
                    registered_apps_names.append(app['model']._meta.model_name)
        else:
            for app in registered_apps:
                if app['verbose_name'].lower() == 'user':
                    try:
                        models_index = registered_apps_models.index(app['model'])
                        registered_apps_models.pop(models_index)
                        names_index = registered_apps_names.index(app['model']._meta.model_name)
                        registered_apps_names.pop(names_index)
                    except Exception as e:
                        pass

        self.models = registered_apps_models
        self.fields['models'] = forms.MultipleChoiceField(choices=model_choices(), required=False, label=_('Search In'), widget=forms.CheckboxSelectMultiple)
开发者ID:BIGGANI,项目名称:tendenci,代码行数:28,代码来源:forms.py


示例8: get_theme

def get_theme():
    request = get_current_request()
    if request:
        theme = request.session.get('theme', get_setting('module', 'theme_editor', 'theme'))
    else:
        theme = get_setting('module', 'theme_editor', 'theme')
    return theme
开发者ID:BIGGANI,项目名称:tendenci,代码行数:7,代码来源:utils.py


示例9: send_registration_activation_email

def send_registration_activation_email(user, registration_profile, **kwargs):
    """
        this function sends the activation email to the self registrant.
        modified based on the block in create_inactive_user in registration/models.py
    """
    from django.core.mail import send_mail
    from django.template.loader import render_to_string
    from django.conf import settings
    from tendenci.apps.site_settings.utils import get_setting

    event = kwargs.pop('event', None)
    event_url = None
    if event: event_url = event.get_absolute_url()

    next = kwargs.pop('next', '')

    site_url = get_setting('site', 'global', 'siteurl')
    subject = render_to_string('registration/activation_email_subject.txt',
                                       { 'site_url': site_url })

    # Email subject *must not* contain newlines
    subject = ''.join(subject.splitlines())
    message = render_to_string('registration/activation_email.txt',
                               { 'activation_key': registration_profile.activation_key,
                                 'expiration_days': settings.ACCOUNT_ACTIVATION_DAYS,
                                 'event_url': event_url,
                                 'site_url': site_url,
                                 'next': next })

    from_email = get_setting('site', 'global', 'siteemailnoreplyaddress') or settings.DEFAULT_FROM_EMAIL

    send_mail(subject, message, from_email, [user.email])
开发者ID:goetzk,项目名称:tendenci,代码行数:32,代码来源:utils.py


示例10: get_gravatar_url

    def get_gravatar_url(self, size):
        # Use old avatar, if exists, as the default
        default = ''
        if get_setting('module', 'users', 'useoldavatarasdefault'):
            c = connection.cursor()
            try:
                c.execute("select avatar from avatar_avatar where \"primary\"='t' and user_id=%d" % self.user.id)
                row = c.fetchone()
                if row and os.path.exists(os.path.join(settings.MEDIA_ROOT, row[0])):
                    default = '%s%s%s' %  (get_setting('site', 'global', 'siteurl'),
                                       settings.MEDIA_URL,
                                       row[0])
            except ProgrammingError:
                pass

            c.close()

        if not default:
            default = '%s%s%s' %  (get_setting('site', 'global', 'siteurl'),
                                   getattr(settings, 'STATIC_URL', ''),
                                   settings.GAVATAR_DEFAULT_URL)

        gravatar_url = "//www.gravatar.com/avatar/" + self.getMD5() + "?"
        gravatar_url += urllib.urlencode({'d':default, 's':str(size)})
        return gravatar_url
开发者ID:goetzk,项目名称:tendenci,代码行数:25,代码来源:models.py


示例11: enabled

 def enabled(cls):
     """Return backend enabled status by checking Setting Model"""
     try:
         FACEBOOK_APP_ID = get_setting(scope='module', scope_category='users', name='facebook_app_id')
         FACEBOOK_API_SECRET = get_setting(scope='module', scope_category='users', name='facebook_api_secret')
     except Setting.DoesNotExist:
         return False
     return True
开发者ID:goetzk,项目名称:tendenci,代码行数:8,代码来源:facebook.py


示例12: get_title

    def get_title(self):
        obj = self.object

        ### Assign variables -----------------------
        primary_keywords = get_setting('site', 'global', 'siteprimarykeywords')
        geo_location = get_setting('site', 'global', 'sitegeographiclocation')
        #site_name = get_setting('site', 'global', 'sitedisplayname')  # Not currently used
        category_set = obj.category_set
        category = category_set.get('category', '')
        subcategory = category_set.get('sub_category', '')

        contact_name = '%s %s' % (
            obj.first_name,
            obj.last_name
        )
        contact_name = contact_name.strip()

        ### Build string -----------------------
        values_list = []
        if obj.headline:
            values_list.append(obj.headline)

        if obj.headline and obj.release_dt:
            values_list.append('-')
        if obj.release_dt:
            values_list.append(obj.release_dt.strftime('%m-%d-%Y'))

        if primary_keywords:
            if values_list:
                values_list.append(':')
                values_list.append(primary_keywords)
        else:
            if category and subcategory:
                values_list.append('category')
                values_list.append(':')
                values_list.append('subcategory')
            elif category:
                values_list.append('category')

        if contact_name:
            values_list.append('contact: %s' % contact_name)

        if geo_location:
            values_list.append('in %s' % geo_location)
        # commenting out to avoid the duplicates - the site name
        # is included on base.html already.
#        if site_name:
#            if values_list:
#                values_list.append('|')
#            values_list.append(site_name)

        title = ' '.join(values_list)
        # truncate the meta title to 100 characters
        max_length = 100
        if len(title) > max_length:
            title = '%s...' % title[:(max_length - 3)]

        return title
开发者ID:tendenci,项目名称:tendenci,代码行数:58,代码来源:module_meta.py


示例13: clean_password1

    def clean_password1(self):
        password1 = self.cleaned_data.get('password1')
        password_regex = get_setting('module', 'users', 'password_requirements_regex')
        password_requirements = get_setting('module', 'users', 'password_text')
        if password_regex:
            if not re.match(password_regex, password1):
                raise forms.ValidationError(mark_safe(_("The password does not meet the requirements: %(p)s" % {'p': password_requirements })))

        return password1
开发者ID:jiwonlee777,项目名称:tendenci,代码行数:9,代码来源:forms.py


示例14: get_title

    def get_title(self):
        obj = self.object

        ### Assign variables -----------------------
        primary_keywords = get_setting('site','global','siteprimarykeywords')
        geo_location = get_setting('site','global','sitegeographiclocation')
        site_name = get_setting('site','global','sitedisplayname')
        category = Category.objects.get_for_object(obj, 'category')
        subcategory = Category.objects.get_for_object(obj, 'subcategory')

        contact_name = '%s %s' % (
            obj.first_name,
            obj.last_name
        )
        contact_name = contact_name.strip()

        ### Build string -----------------------
        values_list = []
        if obj.headline:
            values_list.append(obj.headline)

        if obj.headline and obj.release_dt:
            values_list.append('-')
        if obj.release_dt:
            values_list.append(obj.release_dt.strftime('%m-%d-%Y'))

        if primary_keywords:
            if values_list:
                values_list.append(':')
                values_list.append(primary_keywords)
        else:
            if category and subcategory:
                values_list.append('category')
                values_list.append(':')
                values_list.append('subcategory')
            elif category:
                values_list.append('category')

        if site_name:
            if values_list:
                values_list.append('news for')
            values_list.append(site_name)

        if contact_name:
            values_list.append('contact: %s' % contact_name)

        if geo_location:
            values_list.append('in %s' % geo_location)

        title = ' '.join(values_list)
        # truncate the meta title to 100 characters
        max_length = 100
        if len(title) > max_length:
            title = '%s...' % title[:(max_length - 3)]

        return title
开发者ID:BIGGANI,项目名称:tendenci,代码行数:56,代码来源:module_meta.py


示例15: robots_txt

def robots_txt(request):
    options = ['base/robots_private.txt', 'base/robots_public.txt', 'robots.txt']
    template_name = "robots.txt"

    robots_setting = get_setting('site', 'global', 'robotstxt')
    if robots_setting in options:
        template_name = robots_setting

    site_url = get_setting('site', 'global', 'siteurl')
    return render_to_response(template_name, {'site_url': site_url}, context_instance=RequestContext(request), content_type="text/plain")
开发者ID:ediaz1,项目名称:tendenci,代码行数:10,代码来源:views.py


示例16: get_admin_emails

 def get_admin_emails():
     admin_emails = get_setting('module', 'corporate_memberships',
                                'corporatemembershiprecipients').strip()
     if admin_emails:
         admin_emails = admin_emails.split(',')
     if not admin_emails:
         admin_emails = (get_setting('site', 'global',
                                     'admincontactemail'
                                     ).strip()).split(',')
     return admin_emails
开发者ID:BIGGANI,项目名称:tendenci,代码行数:10,代码来源:send_corp_membership_notices.py


示例17: __init__

    def __init__(self, *args, **kwargs):
        super(LoginForm, self).__init__(*args, **kwargs)
        # check if we need to hide the remember me checkbox
        # and set the default value for remember me
        hide_remember_me = get_setting('module', 'users', 'usershiderememberme')
        remember_me_default_checked = get_setting('module', 'users', 'usersremembermedefaultchecked')

        if remember_me_default_checked:
            self.fields['remember'].initial = True
        if hide_remember_me:
            self.fields['remember'].widget = forms.HiddenInput()
开发者ID:jiwonlee777,项目名称:tendenci,代码行数:11,代码来源:forms.py


示例18: clean_new_password1

    def clean_new_password1(self):
        password1 = self.cleaned_data.get('new_password1')
        password_regex = get_setting('module', 'users', 'password_requirements_regex')
        password_requirements = get_setting('module', 'users', 'password_text')
        if password_regex:
            # At least MIN_LENGTH long
            # "^(?=.{8,})(?=.*[0-9=]).*$"
            if not re.match(password_regex, password1):
                raise forms.ValidationError(mark_safe("The new password does not meet the requirements </li><li>%s" % password_requirements))

        return password1
开发者ID:RMUCapstone-MIS590,项目名称:tendenci,代码行数:11,代码来源:forms.py


示例19: encode_site

def encode_site(xml):
    xml.write("<title>%s</title>"%get_setting('site', 'global', 'sitedisplayname'), depth=1)
    xml.write("<description></description>", depth=1)
    xml.write("<pubDate>%s</pubDate>"%datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), depth=1)
    xml.write("<language>%s</language>"%get_setting('site', 'global', 'localizationlanguage'), depth=1)
    xml.write("<wp:wxr_version>%s</wp:wxr_version>"%1.0, depth=1)
    # not sure if this is required
    #xml.write("<wp:base_site_url>http://wordpress.com/</wp:base_site_url>", depth=1)
    #xml.write("<wp:base_blog_url>http://sambixly.wordpress.com</wp:base_blog_url>", depth=1)
    encode_categories(xml)
    encode_tags(xml)
开发者ID:BIGGANI,项目名称:tendenci,代码行数:11,代码来源:utils.py


示例20: get_admin_emails

    def get_admin_emails(self):
        payment_admins = get_setting("module", "payments", "paymentrecipients")
        if payment_admins:
            payment_admins = payment_admins.split(",")
            admin_emails = payment_admins
        else:
            admin_emails = (get_setting("site", "global", "admincontactemail")).split(",")

        if admin_emails:
            admin_emails = ",".join(admin_emails)

        return admin_emails
开发者ID:ZHW123,项目名称:tendenci,代码行数:12,代码来源:utils.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python shortcuts.render_to_resp函数代码示例发布时间:2022-05-27
下一篇:
Python site.register函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap