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


Python utils.get_setting函数代码示例

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


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


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