本文整理汇总了Python中mezzanine.accounts.get_profile_model函数的典型用法代码示例。如果您正苦于以下问题:Python get_profile_model函数的具体用法?Python get_profile_model怎么用?Python get_profile_model使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_profile_model函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: account_data
def account_data(self, test_value):
"""
Returns a dict with test data for all the user/profile fields.
"""
# User fields
data = {"email": test_value + "@example.com"}
for field in ("first_name", "last_name", "username",
"password1", "password2"):
if field.startswith("password"):
value = "x" * settings.ACCOUNTS_MIN_PASSWORD_LENGTH
else:
value = test_value
data[field] = value
# Profile fields
Profile = get_profile_model()
if Profile is not None:
user_fieldname = get_profile_user_fieldname()
for field in Profile._meta.fields:
if field.name not in (user_fieldname, "id"):
if field.choices:
value = field.choices[0][0]
else:
value = test_value
data[field.name] = value
return data
开发者ID:orlenko,项目名称:sfpirg,代码行数:25,代码来源:tests.py
示例2: account_data
def account_data(self, test_value):
"""
Returns a dict with test data for all the user/profile fields.
"""
# User fields
data = {"email": test_value + "@example.com"}
for field in ("first_name", "last_name", "username",
"password1", "password2"):
if field.startswith("password"):
value = "x" * settings.ACCOUNTS_MIN_PASSWORD_LENGTH
else:
value = test_value
data[field] = value
# Profile fields
Profile = get_profile_model()
if Profile is not None:
from mezzanine.accounts.forms import ProfileFieldsForm
user_fieldname = get_profile_user_fieldname()
for name, field in ProfileFieldsForm().fields.items():
if name not in (user_fieldname, "id"):
if hasattr(field, "choices"):
value = list(field.choices)[0][0]
elif isinstance(field, (DateField, DateTimeField)):
value = "9001-04-20"
else:
value = test_value
data[name] = value
return data
开发者ID:peopleco,项目名称:mezzanine,代码行数:28,代码来源:tests.py
示例3: karma
def karma(sender, **kwargs):
"""
Each time a rating is saved, check its value and modify the
profile karma for the related object's user accordingly.
Since ratings are either +1/-1, if a rating is being edited,
we can assume that the existing rating is in the other direction,
so we multiply the karma modifier by 2.
"""
rating = kwargs["instance"]
value = int(rating.value)
if not kwargs["created"]:
value *= 2
content_object = rating.content_object
if rating.user != content_object.user:
queryset = get_profile_model().objects.filter(user=content_object.user)
queryset.update(karma=models.F("karma") + value)
开发者ID:phodal,项目名称:xunta,代码行数:16,代码来源:models.py
示例4: profile
def profile(request, username, template="accounts/account_profile.html"):
"""
Display a profile.
"""
profile_user = get_object_or_404(User, username=username, is_active=True)
profile_fields = SortedDict()
Profile = get_profile_model()
if Profile is not None:
profile = profile_user.get_profile()
user_fieldname = get_profile_user_fieldname()
exclude = tuple(settings.ACCOUNTS_PROFILE_FORM_EXCLUDE_FIELDS)
for field in Profile._meta.fields:
if field.name not in ("id", user_fieldname) + exclude:
value = getattr(profile, field.name)
profile_fields[field.verbose_name.title()] = value
context = {"profile_user": profile_user, "profile_fields": profile_fields.items()}
return render(request, template, context)
开发者ID:niotech,项目名称:mezzanine,代码行数:17,代码来源:views.py
示例5: profile_fields
def profile_fields(user):
"""
Returns profile fields as a dict for the given user. Used in the
profile view template when the ``ACCOUNTS_PROFILE_VIEWS_ENABLED``
setting is set to ``True``, and also in the account approval emails
sent to administrators when the ``ACCOUNTS_APPROVAL_REQUIRED``
setting is set to ``True``.
"""
fields = SortedDict()
Profile = get_profile_model()
if Profile is not None:
profile = user.get_profile()
user_fieldname = get_profile_user_fieldname()
exclude = tuple(settings.ACCOUNTS_PROFILE_FORM_EXCLUDE_FIELDS)
for field in Profile._meta.fields:
if field.name not in ("id", user_fieldname) + exclude:
value = getattr(profile, field.name)
fields[field.verbose_name.title()] = value
return list(fields.items())
开发者ID:11m09d,项目名称:weixin_market,代码行数:19,代码来源:accounts_tags.py
示例6: karma
def karma(sender, **kwargs):
"""
Each time a rating is saved, check its value and modify the
profile karma for the related object's user accordingly.
Since ratings are either +1/-1, if a rating is being edited,
we can assume that the existing rating is in the other direction,
so we multiply the karma modifier by 2. We also run this when
a rating is deleted (undone), in which case we just negate the
rating value from the karma.
"""
rating = kwargs["instance"]
value = int(rating.value)
if "created" not in kwargs:
value *= -1 # Rating deleted
elif not kwargs["created"]:
value *= 2 # Rating changed
content_object = rating.content_object
if rating.user != content_object.user:
queryset = get_profile_model().objects.filter(user=content_object.user)
queryset.update(karma=models.F("karma") + value)
开发者ID:christabella,项目名称:voices,代码行数:20,代码来源:models.py
示例7: _
_("Invalid username/email and password"))
elif not self._user.is_active:
raise forms.ValidationError(_("Your account is inactive"))
return self.cleaned_data
def save(self):
"""
Just return the authenticated user - used for logging in.
"""
return getattr(self, "_user", None)
# If a profile model has been configured with the ``AUTH_PROFILE_MODULE``
# setting, create a model form for it that will have its fields added to
# ``ProfileForm``.
Profile = get_profile_model()
_exclude_fields = tuple(settings.ACCOUNTS_PROFILE_FORM_EXCLUDE_FIELDS)
if Profile is not None:
class ProfileFieldsForm(forms.ModelForm):
class Meta:
model = Profile
exclude = (get_profile_user_fieldname(),) + _exclude_fields
class ProfileForm(Html5Mixin, forms.ModelForm):
"""
ModelForm for auth.User - used for signup and profile update.
If a Profile model is defined via ``AUTH_PROFILE_MODULE``, its
fields are injected into the form.
"""
开发者ID:andreyshipilov,项目名称:mezzanine,代码行数:30,代码来源:forms.py
示例8: FileSystemStorage
from mezzanine.pages.models import RichTextPage
from links.forms import LinkForm
from links.models import Link
from links.utils import order_by_score
from theme.models import Portfolio, PortfolioItem, Certificate, ArtigoFinal
fs = FileSystemStorage(location=settings.FORMS_UPLOAD_ROOT)
# Returns the name to be used for reverse profile lookups from the user
# object. That's "profile" for the ``links.Profile``, but otherwise
# depends on the model specified in ``AUTH_PROFILE_MODULE``.
USER_PROFILE_RELATED_NAME = get_profile_model().user.field.related_query_name()
class UserFilterView(ListView):
"""
List view that puts a ``profile_user`` variable into the context,
which is optionally retrieved by a ``username`` urlpattern var.
If a user is loaded, ``object_list`` is filtered by the loaded
user. Used for showing lists of links and comments.
"""
def get_context_data(self, **kwargs):
context = super(UserFilterView, self).get_context_data(**kwargs)
try:
username = self.kwargs["username"]
except KeyError:
开发者ID:efraimmgon,项目名称:apliemt,代码行数:31,代码来源:views.py
示例9: getattr
LOGOUT_URL = settings.LOGOUT_URL
PROFILE_URL = getattr(settings, "PROFILE_URL", "/users/")
PROFILE_UPDATE_URL = getattr(settings, "PROFILE_UPDATE_URL",
"/account/update/")
PASSWORD_RESET_URL = getattr(settings, "PASSWORD_RESET_URL",
"/account/password/reset/")
PASSWORD_RESET_VERIFY_URL = getattr(settings, "PASSWORD_RESET_VERIFY_URL",
"/account/password/verify/")
verify_pattern = "/(?P<uidb36>[-\w]+)/(?P<token>[-\w]+)/$"
urlpatterns = patterns("mezzanine.accounts.views",
url("^%s/$" % LOGIN_URL.strip("/"), "login", name="login"),
url("^%s/$" % LOGOUT_URL.strip("/"), "logout", name="logout"),
url("^%s/$" % SIGNUP_URL.strip("/"), "signup", name="signup"),
url("^%s%s" % (SIGNUP_VERIFY_URL.strip("/"), verify_pattern),
"signup_verify", name="signup_verify"),
url("^%s/$" % PROFILE_UPDATE_URL.strip("/"), "profile_update",
name="profile_update"),
url("^%s/$" % PASSWORD_RESET_URL.strip("/"), "password_reset",
name="mezzanine_password_reset"),
url("^%s%s" % (PASSWORD_RESET_VERIFY_URL.strip("/"), verify_pattern),
"password_reset_verify", name="password_reset_verify"),
)
if get_profile_model():
urlpatterns += patterns("mezzanine.accounts.views",
url("^%s/(?P<username>.*)/$" % PROFILE_URL.strip("/"), "profile",
name="profile"),
)
开发者ID:a5an0,项目名称:mezzanine,代码行数:30,代码来源:urls.py
注:本文中的mezzanine.accounts.get_profile_model函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论