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

Python utils.get_setting函数代码示例

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

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



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

示例1: __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 is_admin(kwargs['user']) 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.module_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.module_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:BakethemPie,项目名称:tendenci,代码行数:28,代码来源:forms.py


示例2: 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:BakethemPie,项目名称:tendenci,代码行数:26,代码来源:module_meta.py


示例3: get_keywords

    def get_keywords(self):
        object = self.object

        ### Assign variables -----------------------
        dynamic_keywords = generate_meta_keywords(object.body)
        primary_keywords = get_setting("site", "global", "siteprimarykeywords")
        secondary_keywords = get_setting("site", "global", "sitesecondarykeywords")
        geo_location = get_setting("site", "global", "sitegeographiclocation")
        site_name = get_setting("site", "global", "sitedisplayname")

        creator_name = "%s %s" % (object.creator.first_name, object.creator.last_name)

        ### Build string -----------------------
        value = ""

        if primary_keywords:
            value = "%s %s" % (value, primary_keywords)
            value = value.strip()

        if object.headline:
            list = ["Articles", geo_location, site_name, "white paper", creator_name]

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

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

        else:
            list = ["Articles", geo_location, site_name, "white paper", secondary_keywords]
            value = "%s %s" % (value, "".join(list))

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


示例4: 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:BakethemPie,项目名称:tendenci,代码行数:27,代码来源:module_meta.py


示例5: 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 </li><li>%s" % password_requirements))

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


示例6: get_admin_emails

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


示例7: 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:BakethemPie,项目名称:tendenci,代码行数:11,代码来源:utils.py


示例8: get_title

    def get_title(self):
        object = 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_set = object.category_set
        category = category_set.get('category', '')
        subcategory = category_set.get('sub_category', '')

        creator_name = '%s %s' % (
            object.creator.first_name, 
            object.creator.last_name
        )
        creator_name = creator_name.strip()

        ### Build string -----------------------
        value = '%s - %s' % (object.headline, object.activation_dt)
        value = value.strip()

        value = ''

        # start w/ headline
        if object.headline:
            value += object.headline

        # contact activation
        if object.headline and object.activation_dt:
            value += ' - %s' % object.activation_dt.strftime('%m-%d-%Y')
        elif object.activation_dt:
            value += object.activation_dt.strftime('%m-%d-%Y')

        # primary keywords OR category/subcategory
        if primary_keywords:
            value = '%s : %s' % (value, primary_keywords)
        else:
            if category:
                value = '%s %s' % (value, category)
            if category and subcategory:
                value = '%s : %s' % (value, subcategory)

        value = '%s directory' % value

        if creator_name:
            value = '%s contact: %s' % (value, creator_name)

        value = '%s directories for %s' % (value, site_name)

        if geo_location:
            value = '%s in %s' % (value, geo_location)

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


示例9: 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')
        print password_regex
        print password_requirements
        if password_regex:
            # At least MIN_LENGTH long
            # "^(?=.{8,})(?=.*[0-9=]).*$"
            print re.match(password_regex, password1)
            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:BakethemPie,项目名称:tendenci,代码行数:14,代码来源:forms.py


示例10: get_title

    def get_title(self):
        object = 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_set = object.category_set
        category = category_set.get("category", "")
        subcategory = category_set.get("sub_category", "")

        creator_name = "%s %s" % (object.creator.first_name, object.creator.last_name)
        creator_name = creator_name.strip()

        ### Build string -----------------------
        value = "%s - %s" % (object.headline, object.release_dt)
        value = value.strip()

        value = ""

        # start w/ headline
        if object.headline:
            value += object.headline

        # contact release
        if object.headline and object.release_dt:
            value += " - %s" % object.release_dt.strftime("%m-%d-%Y")
        elif object.release_dt:
            value += object.release_dt.strftime("%m-%d-%Y")

        # primary keywords OR category/subcategory
        if primary_keywords:
            value = "%s : %s" % (value, primary_keywords)
        else:
            if category:
                value = "%s %s" % (value, category)
            if category and subcategory:
                value = "%s : %s" % (value, subcategory)

        value = "%s article" % value

        if creator_name:
            value = "%s contact: %s" % (value, creator_name)

        value = "%s articles for %s" % (value, site_name)

        if geo_location:
            value = "%s in %s" % (value, geo_location)

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


示例11: template_update

def template_update(request, template_id):
    """
    This method makes use of the same files to update the CM Template.
    Useful for updating data/content only and retaining design.
    """

    template = get_object_or_404(Template, template_id=template_id)

    if not has_perm(request.user, 'campaign_monitor.change_template',
                    template):
        raise Http403

    #set up urls
    site_url = get_setting('site', 'global', 'siteurl')
    html_url = str("%s%s" % (site_url, template.get_html_url()))
    if template.zip_file:
        zip_url = str("%s%s" % (site_url, template.get_zip_url()))
    else:
        zip_url = ""

    #sync with campaign monitor
    try:
        t = CST(template_id=template.template_id)
        t.update(str(template.name), html_url, zip_url)
    except BadRequest, e:
        messages.add_message(
            request, messages.ERROR,
            'Bad Request %s: %s' % (e.data.Code, e.data.Message))
        return redirect(template)
开发者ID:neopunisher,项目名称:tendenci,代码行数:29,代码来源:views.py


示例12: search

def search(request, template_name="locations/search.html"):
    query = request.GET.get('q', None)

    if get_setting('site', 'global', 'searchindex') and query:
        locations = Location.objects.search(query, user=request.user)
    else:
        filters = get_query_filters(request.user, 'locations.view_location')
        locations = Location.objects.filter(filters).distinct()
        if not request.user.is_anonymous():
            locations = locations.select_related()

    locations = locations.order_by('-create_dt')

    log_defaults = {
        'event_id' : 834000,
        'event_data': '%s listed by %s' % ('Location', request.user),
        'description': '%s listed' % 'Location',
        'user': request.user,
        'request': request,
        'source': 'locations'
    }
    EventLog.objects.log(**log_defaults)
    
    return render_to_response(template_name, {'locations':locations}, 
        context_instance=RequestContext(request))
开发者ID:BakethemPie,项目名称:tendenci,代码行数:25,代码来源:views.py


示例13: index

def index(request, cat_slug=None, template_name="videos/list.html"):
    """
    This page lists out all videos. The order can be customized.
    Filtering by category only works if a search index is available.
    """
    has_index = get_setting('site', 'global', 'searchindex')

    if has_index and cat_slug:
        videos = Video.objects.search('cat:%s' % cat_slug, user=request.user)
        videos = videos.order_by('-ordering','-create_dt')
        category = get_object_or_404(Category, slug=cat_slug)
    else:
        filters = get_query_filters(request.user, 'videos.view_video')
        videos = Video.objects.filter(filters).distinct()
        if request.user.is_authenticated():
            videos = videos.select_related()
        videos = videos.order_by('-ordering', '-create_dt')

    categories = Category.objects.all()

    EventLog.objects.log(**{
        'event_id' : 1200400,
        'event_data': '%s viewed by %s' % ('Video list', request.user),
        'description': '%s viewed' % 'Video',
        'user': request.user,
        'request': request,
        'source': 'video',
    })

    return render_to_response(template_name, locals(), 
        context_instance=RequestContext(request))
开发者ID:BakethemPie,项目名称:tendenci,代码行数:31,代码来源:views.py


示例14: photoset_details

def photoset_details(request, id, template_name="photos/photo-set/details.html"):
    """ View photos in photo set """
    
    photo_set = get_object_or_404(PhotoSet, id=id)
    if not has_view_perm(request.user, 'photos.view_photoset', photo_set):
        raise Http403
    
    order = get_setting('module', 'photos', 'photoordering')
    if order == 'descending':
        photos = photo_set.get_images(user=request.user).order_by('-pk')
    else:
        photos = photo_set.get_images(user=request.user).order_by('pk')
    
    EventLog.objects.log(**{
        'event_id' : 991500,
        'event_data': '%s (%d) viewed by %s' % (photo_set._meta.object_name, photo_set.pk, request.user),
        'description': '%s viewed' % photo_set._meta.object_name,
        'user': request.user,
        'request': request,
        'instance': photo_set,
    })

    return render_to_response(template_name, {
        "photos": photos,
        "photo_set": photo_set,
    }, context_instance=RequestContext(request))
开发者ID:BakethemPie,项目名称:tendenci,代码行数:26,代码来源:views.py


示例15: photoset_view_latest

def photoset_view_latest(request, template_name="photos/photo-set/latest.html"):
    """ View latest photo set """

    query = request.GET.get('q', None)
    if get_setting('site', 'global', 'searchindex') and query:
        photo_sets = PhotoSet.objects.search(query, user=request.user)
    else:
        filters = get_query_filters(request.user, 'photos.view_photoset')
        photo_sets = PhotoSet.objects.filter(filters).distinct()
        if not request.user.is_anonymous():
            photo_sets = photo_sets.select_related()
    photo_sets = photo_sets.order_by('-create_dt')

    log_defaults = {
        'event_id' : 991400,
        'event_data': '%s searched by %s' % ('PhotoSet', request.user),
        'description': '%s searched' % 'PhotoSet',
        'user': request.user,
        'request': request,
        'source': 'photos'
    }
    EventLog.objects.log(**log_defaults)

    return render_to_response(template_name, {"photo_sets": photo_sets}, 
        context_instance=RequestContext(request))
开发者ID:BakethemPie,项目名称:tendenci,代码行数:25,代码来源:views.py


示例16: user_sqs

def user_sqs(sqs, **kwargs):
    """
    people between admin and anon permission
    (status+status_detail+(anon OR user)) OR (who_can_view__exact)
    """
    user = kwargs.get('user')
    member_perms = get_setting('module', 'memberships', 'memberprotection')

    anon_q = Q(allow_anonymous_view=True)
    user_q = Q(allow_user_view=True)
    status_q = Q(status=1, status_detail='active')
    perm_q = Q(users_can_view__in=user.username)

    q = reduce(operator.or_, [anon_q, user_q])
    q = reduce(operator.and_, [status_q, q])
    q = reduce(operator.or_, [q, perm_q])

    filtered_sqs = sqs.filter(q)
    if not is_member(user):
        # all-members means members can view all other members
        if member_perms == "all-members":
            filtered_sqs = filtered_sqs.none()
        # member type means members can only view members of their same type
        if member_perms == "member-type":
            filtered_sqs = filtered_sqs.none()

    return filtered_sqs
开发者ID:BakethemPie,项目名称:tendenci,代码行数:27,代码来源:managers.py


示例17: get_corporate_membership_type_choices

def get_corporate_membership_type_choices(user, corpapp, renew=False):
    cmt_list = []
    corporate_membership_types = corpapp.corp_memb_type.all()
    
    if not is_admin(user):
        corporate_membership_types = corporate_membership_types.filter(admin_only=False)
    currency_symbol = get_setting("site", "global", "currencysymbol")
    
    for cmt in corporate_membership_types:
        if not renew:
            price_display = '%s - %s%0.2f' % (cmt.name, currency_symbol, cmt.price)
        else:
            indiv_renewal_price = cmt.membership_type.renewal_price
            if not indiv_renewal_price:
                indiv_renewal_price = 'Free<span class="type-ind-price"></span>'
            else:
                indiv_renewal_price = '%s<span class="type-ind-price">%0.2f</span>' % (currency_symbol, indiv_renewal_price)
            if not cmt.renewal_price:
                cmt.renewal_price = 0
            
            price_display = """%s - <b>%s<span class="type-corp-price">%0.2f</span></b> 
                            (individual members renewal: 
                            <b>%s</b>)""" % (cmt.name, 
                                            currency_symbol, 
                                            cmt.renewal_price,
                                            indiv_renewal_price)
        price_display = mark_safe(price_display)
        cmt_list.append((cmt.id, price_display))
            
    return cmt_list 
开发者ID:BakethemPie,项目名称:tendenci,代码行数:30,代码来源:utils.py


示例18: payment_processing_object_updates

def payment_processing_object_updates(request, payment, **kwargs):
    # they are paid, so update the object
    # trap the error and send us the error email - just in case
    try:
        if str(payment.response_code) == '1' and str(payment.response_reason_code) == '1':
            obj = payment.invoice.get_object()
            if obj and hasattr(obj, 'auto_update_paid_object'):
                obj.auto_update_paid_object(request, payment)
    except:
        import traceback
        from django.core.mail import send_mail
        from django.conf import settings
        from site_settings.utils import get_setting
        
        err_msg = traceback.format_exc()
        subject = 'Payment error from %s (ID:%d)' % (get_setting('site', 'global', 'siteurl'), 
                                                     payment.id)
        body = err_msg
        sender = settings.DEFAULT_FROM_EMAIL
        admins = settings.ADMINS
        recipients = [item[1] for item in admins]
        if not recipients:
            recipients = ['[email protected]']
        send_mail(subject, body, sender, recipients, fail_silently=True)
        
        # still want the end user know an error occurred
        raise Exception, err_msg
开发者ID:BakethemPie,项目名称:tendenci,代码行数:27,代码来源:utils.py


示例19: search

def search(request, template_name="staff/search.html"):
    """Staff plugin search list view"""
    query = request.GET.get('q', None)

    if get_setting('site', 'global', 'searchindex') and query:
        staff = Staff.objects.search(query, user=request.user)
    else:
        filters = get_query_filters(request.user, 'staff.view_staff')
        staff = Staff.objects.filter(filters).distinct()
        if not request.user.is_anonymous():
            staff = staff.select_related()

    staff = staff.order_by('-status','status_detail','start_date')
    
    log_defaults = {
        'event_id' : 1080400,
        'event_data': '%s searched by %s' % ('Staff', request.user),
        'description': '%s searched' % 'Staff',
        'user': request.user,
        'request': request,
        'source': 'staff'
    }
    EventLog.objects.log(**log_defaults)

    return render_to_response(template_name, {'staff_members':staff},
        context_instance=RequestContext(request))
开发者ID:BakethemPie,项目名称:tendenci,代码行数:26,代码来源:views.py


示例20: email_script_errors

 def email_script_errors(err_msg):
     """Send error message to us in case of an error.
     """
     email = Email()
     email.sender = get_setting('site', 'global', 'siteemailnoreplyaddress')
     email.sender_display = get_setting('site', 'global', 'sitedisplayname')
     site_url = get_setting('site', 'global', 'siteurl')
 
     now = datetime.now()
     nowstr = time.strftime("%d-%b-%y %I:%M %p", now.timetuple())
     email.recipient = get_script_support_emails()
     if email.recipient:
         email.body = '%s \n\nTime Submitted: %s\n' % (err_msg, nowstr)
         email.content_type = "text"
         email.subject = 'Error Setting Up Campaign Monitor Account on New Site %s' % site_url
         
         email.send()
开发者ID:BakethemPie,项目名称:tendenci,代码行数:17,代码来源:setup_campaign_monitor.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python utils.get_config函数代码示例发布时间:2022-05-27
下一篇:
Python site_helper.storage函数代码示例发布时间: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