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


Python utils.get_setting函数代码示例

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


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

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

示例2: get_max_file_upload_size

def get_max_file_upload_size(file_module=False):
    global_max_upload_size = (
        get_setting("site", "global", "maxfilesize") or "26214400"
    )  # default value if ever site setting is missing
    if file_module:
        return int(get_setting("module", "files", "maxfilesize") or global_max_upload_size)
    return int(global_max_upload_size)
开发者ID:simonqiang,项目名称:tendenci,代码行数:7,代码来源:utils.py

示例3: search

def search(request, template_name="profiles/search.html"):
    # check if allow anonymous user search
    allow_anonymous_search = get_setting('module', 'users', 'allowanonymoususersearchuser')
    allow_user_search = get_setting('module', 'users', 'allowusersearch')

    if request.user.is_anonymous():
        if not allow_anonymous_search:
            raise Http403

    if request.user.is_authenticated():
        if not allow_user_search and not request.user.profile.is_superuser:
            raise Http403

    query = request.GET.get('q', None)
    filters = get_query_filters(request.user, 'profiles.view_profile')
    profiles = Profile.objects.filter(filters).distinct()

    if query:
        profiles = profiles.filter(Q(user__first_name__icontains=query) | Q(user__last_name__icontains=query) | Q(user__email__icontains=query) | Q(user__username__icontains=query))

    profiles = profiles.order_by('user__last_name', 'user__first_name')

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

    return render_to_response(template_name, {'profiles':profiles, "user_this":None}, 
        context_instance=RequestContext(request))
开发者ID:legutierr,项目名称:tendenci,代码行数:34,代码来源:views.py

示例4: __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.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:legutierr,项目名称:tendenci,代码行数:28,代码来源:forms.py

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

示例6: get_search_filter

 def get_search_filter(user):
     if user.profile.is_superuser: return None, None
     
     filter_and, filter_or = None, None
     
     allow_anonymous_search = get_setting('module', 
                                  'corporate_memberships', 
                                  'anonymoussearchcorporatemembers')
     allow_member_search = get_setting('module', 
                               'corporate_memberships', 
                               'membersearchcorporatemembers')
     
     if allow_anonymous_search or (allow_member_search and user.profile.is_member):
         filter_and =  {'status':1,
                        'status_detail':'active'}
     else:
         if user.is_authenticated():
             filter_or = {'creator': user,
                          'owner': user}
             if use_search_index:
                 filter_or.update({'reps': user})
             else:
                 filter_or.update({'reps__user': user})
         else:
             filter_and = {'allow_anonymous_view':True,}
             
             
     return filter_and, filter_or
开发者ID:eloyz,项目名称:tendenci,代码行数:28,代码来源:models.py

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

示例8: 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.core.site_settings.utils import get_setting

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

    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 })

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

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

示例9: __init__

 def __init__(self, *args, **kwargs):
     if 'user' in kwargs:
         self.user = kwargs.pop('user', None)
     else:
         self.user = None
     super(DonationForm, self).__init__(*args, **kwargs)
     # populate the user fields
     if self.user and self.user.id:
         self.fields['first_name'].initial = self.user.first_name
         self.fields['last_name'].initial = self.user.last_name
         self.fields['email'].initial = self.user.email
         try:
             profile = self.user.get_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
         
     self.fields['payment_method'].widget = forms.RadioSelect(choices=get_payment_method_choices(self.user))
     allocation_str = get_setting('module', 'donations', 'donationsallocations')
     if allocation_str:
         self.fields['allocation'].choices = get_allocation_choices(self.user, allocation_str)
     else:
         del self.fields['allocation']
     preset_amount_str = (get_setting('module', 'donations', 'donationspresetamounts')).strip('')
     if preset_amount_str:
         self.fields['donation_amount'] = forms.ChoiceField(choices=get_preset_amount_choices(preset_amount_str))
开发者ID:fbates,项目名称:tendenci-site,代码行数:34,代码来源:forms.py

示例10: send_welcome_email

def send_welcome_email(user):
    """
    Send email to user account.
    Expects user account else returns false.
    """
    from django.utils.http import int_to_base36
    from django.contrib.auth.tokens import default_token_generator
    from tendenci.core.site_settings.utils import get_setting

    token_generator = default_token_generator

    site_url = get_setting("site", "global", "siteurl")
    site_name = get_setting("site", "global", "sitedisplayname")

    # send new user account welcome email (notification)
    send_emails(
        [user.email],
        "user_welcome",
        {
            "site_url": site_url,
            "site_name": site_name,
            "uid": int_to_base36(user.id),
            "user": user,
            "username": user.username,
            "token": token_generator.make_token(user),
        },
    )
开发者ID:githubber,项目名称:tendenci,代码行数:27,代码来源:utils.py

示例11: membership_search

def membership_search(request, template_name="memberships/search.html"):
    membership_view_perms = get_setting('module', 'memberships', 'memberprotection')

    if not membership_view_perms == "public":
        return HttpResponseRedirect(reverse('profile.search') + "?members=on")

    query = request.GET.get('q')
    mem_type = request.GET.get('type')
    total_count = Membership.objects.all().count()
    if get_setting('site', 'global', 'searchindex') and (total_count > 1000 or query):
        members = Membership.objects.search(query, user=request.user)
        if mem_type:
            members = members.filter(mem_type=mem_type)
        members = members.order_by('last_name')
    else:
        filters = get_query_filters(request.user, 'memberships.view_membership')
        members = Membership.objects.filter(filters).distinct()
        if mem_type:
            members = members.filter(membership_type__pk=mem_type)
        members = members.exclude(status_detail='expired')
        members = members.order_by('user__last_name')
    types = MembershipType.objects.all()

    EventLog.objects.log()

    return render_to_response(template_name, {'members': members, 'types': types},
        context_instance=RequestContext(request))
开发者ID:repos-python,项目名称:tendenci,代码行数:27,代码来源:views.py

示例12: 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:BillTheBest,项目名称:tendenci,代码行数:8,代码来源:facebook.py

示例13: 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_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:BillTheBest,项目名称:tendenci,代码行数:58,代码来源:module_meta.py

示例14: 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:DeepInTheCode,项目名称:tendenci,代码行数:9,代码来源:forms.py

示例15: 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(",")
     if admin_emails:
         admin_emails = ",".join(admin_emails)
     return admin_emails
开发者ID:eltonhoxha,项目名称:tendenci,代码行数:9,代码来源:send_corp_membership_notices.py


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