本文整理汇总了Python中tendenci.apps.site_settings.utils.get_setting函数的典型用法代码示例。如果您正苦于以下问题:Python get_setting函数的具体用法?Python get_setting怎么用?Python get_setting使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_setting函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
示例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
示例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
示例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
示例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
示例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
示例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)
示例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
示例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])
示例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
示例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
示例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
示例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
示例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
示例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")