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


Python Group.description方法代码示例

本文整理汇总了Python中tendenci.apps.user_groups.models.Group.description方法的典型用法代码示例。如果您正苦于以下问题:Python Group.description方法的具体用法?Python Group.description怎么用?Python Group.description使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tendenci.apps.user_groups.models.Group的用法示例。


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

示例1: create_default_group

# 需要导入模块: from tendenci.apps.user_groups.models import Group [as 别名]
# 或者: from tendenci.apps.user_groups.models.Group import description [as 别名]
def create_default_group(sender, app, **kwargs):
    """
    Auto-create a default group with id=1 if none exist.
    """
    if app == "user_groups":
        if not Group.objects.filter(pk=1):
            site_name = "Default"
            table_exists = Setting._meta.db_table in \
                connection.introspection.table_names()
            if table_exists and get_setting("site", "global", "sitedisplayname"):
                site_name = get_setting("site", "global", "sitedisplayname")

            group = Group()
            group.name = site_name
            group.label = site_name
            group.show_as_option = False
            group.allow_self_add = False
            group.allow_self_remove = False
            group.description = "Initial group auto-generated on site creation."
            group.id = 1

            group.save()
开发者ID:repos-python,项目名称:tendenci,代码行数:24,代码来源:__init__.py

示例2: create_default_group

# 需要导入模块: from tendenci.apps.user_groups.models import Group [as 别名]
# 或者: from tendenci.apps.user_groups.models.Group import description [as 别名]
def create_default_group(sender, app, **kwargs):
    """
    Load default groups if none exist
    or create a group with id=1 if not exist.
    """
    def get_site_display_name():
        setting_table_exists = Setting._meta.db_table in \
                    connection.introspection.table_names()
        if setting_table_exists:
            return get_setting("site", "global", "sitedisplayname")
        return ''

    if app == "user_groups":
        site_name = get_site_display_name().strip()
        if not Group.objects.all():
            call_command("loaddata", "default_groups.json")
            if site_name:
                # update the name and label of the first default user group
                group = Group.objects.get(pk=1)
                group.name = site_name
                group.label = site_name
                group.save()
        else:
            if not Group.objects.filter(pk=1):
                if not site_name:
                    site_name = "Default"

                group = Group()
                group.name = site_name
                group.label = site_name
                group.show_as_option = False
                group.allow_self_add = False
                group.allow_self_remove = False
                group.description = "Initial group auto-generated on site creation."
                group.id = 1

                group.save()
开发者ID:BillTheBest,项目名称:tendenci,代码行数:39,代码来源:__init__.py

示例3: save_model

# 需要导入模块: from tendenci.apps.user_groups.models import Group [as 别名]
# 或者: from tendenci.apps.user_groups.models.Group import description [as 别名]
    def save_model(self, request, object, form, change):
        instance = form.save(commit=False)

        # save the expiration method fields
        type_exp_method = form.cleaned_data["type_exp_method"]
        type_exp_method_list = type_exp_method.split(",")
        for i, field in enumerate(form.type_exp_method_fields):
            if field == "fixed_option2_can_rollover":
                if type_exp_method_list[i] == "":
                    type_exp_method_list[i] = ""
            else:
                if type_exp_method_list[i] == "":
                    type_exp_method_list[i] = "0"

            setattr(instance, field, type_exp_method_list[i])

        if not change:
            instance.creator = request.user
            instance.creator_username = request.user.username
            instance.owner = request.user
            instance.owner_username = request.user.username

            # create a group for this type
            group = Group()
            group.name = "Membership: %s" % instance.name
            group.slug = slugify(group.name)
            # just in case, check if this slug already exists in group.
            # if it does, make a unique slug
            tmp_groups = Group.objects.filter(slug__istartswith=group.slug)
            if tmp_groups:
                t_list = [g.slug[len(group.slug) :] for g in tmp_groups]
                num = 1
                while str(num) in t_list:
                    num += 1
                group.slug = "%s%s" % (group.slug, str(num))
                # group name is also a unique field
                group.name = "%s%s" % (group.name, str(num))

            group.label = instance.name
            group.type = "system_generated"
            group.email_recipient = request.user.email
            group.show_as_option = 0
            group.allow_self_add = 0
            group.allow_self_remove = 0
            group.description = "Auto-generated with the membership type. Used for membership only"
            group.notes = "Auto-generated with the membership type. Used for membership only"
            # group.use_for_membership = 1
            group.creator = request.user
            group.creator_username = request.user.username
            group.owner = request.user
            group.owner_username = request.user.username

            group.save()

            instance.group = group

        # save the object
        instance.save()

        # form.save_m2m()

        return instance
开发者ID:simonqiang,项目名称:tendenci,代码行数:64,代码来源:admin.py


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