示例#1
0
def do_group_import(group_object_dict):
    """Creates and Event and Place for the given event_object_dict
    """
    group = Group()

    # assure the correct fields get the right value types
    for field in GROUP_FIELDS:
        if field in group_object_dict:
            field_type = Group._meta.get_field_by_name(field)[0]
            if isinstance(field_type, FloatField):
                setattr(group, field, group_object_dict[field])
            else:
                if field_type.max_length:
                    setattr(
                        group, field,
                        unicode(
                            group_object_dict[field])[:field_type.max_length])
                else:
                    setattr(group, field, unicode(group_object_dict[field]))
    # Since the allow_anonymous_view is not included in the GROUP_FIELDS,
    # set it to False
    group.allow_anonymous_view = False
    group.save()

    return group
示例#2
0
def do_group_import(group_object_dict):
    """Creates and Event and Place for the given event_object_dict
    """
    group = Group()

    # assure the correct fields get the right value types
    for field in GROUP_FIELDS:
        if field in group_object_dict:
            field_type = Group._meta.get_field_by_name(field)[0]
            if isinstance(field_type, FloatField):
                setattr(group, field, group_object_dict[field])
            else:
                if field_type.max_length:
                    setattr(group, field, unicode(group_object_dict[field])[:field_type.max_length])
                else:
                    setattr(group, field, unicode(group_object_dict[field]))
    # Since the allow_anonymous_view is not included in the GROUP_FIELDS,
    # set it to False
    group.allow_anonymous_view = False
    group.save()

    return group