Exemplo n.º 1
0
    def save(self, commit=True):
        group = super(GroupForm, self).save(commit=True)

        if commit:
            group.save()

            # Create and save the group profile
            group_profile = GroupProfile()
            group_profile.group = group

            # Need to add validation for the password fields
            if len(self.cleaned_data['group_password1']) > 0:
                group_profile.set_password(
                    self.cleaned_data['group_password1'])

            group_profile.save()

            # Now we need to actually create folders
            private_folder = Folder()
            private_folder.name = '%s Private' % group.name
            private_folder.notes = 'This folder is private to the %s group' % group.name
            private_folder.save()

            # Give users in this group read and write access to it
            private_folder.setPermissions(group, Actions.WRITE)
            private_folder.save()

            # Now we need to create the public folder for this group
            public_folder = Folder()
            public_folder.name = '%s Public' % group.name
            public_folder.notes = 'This folder is publically viewable and writable memebers of the %s group' % group.name
            public_folder.save()

            # Give any user the ability to read this folder
            anyuser = Group.objects.get(name="anyuser")
            public_folder.setPermissions(anyuser, Actions.READ)

            # Give this group read and write access
            public_folder.setPermissions(group, Actions.WRITE)
            public_folder.save()

            return (group, group_profile, public_folder, private_folder)

        return group
Exemplo n.º 2
0
    def save(self, commit=True):
        group = super(GroupForm, self).save(commit=True)

        if commit:
            group.save()

            # Create and save the group profile
            group_profile = GroupProfile()
            group_profile.group = group

            # Need to add validation for the password fields
            if len(self.cleaned_data['group_password1']) > 0:
                group_profile.set_password(self.cleaned_data['group_password1'])

            group_profile.save()

            # Now we need to actually create folders
            private_folder = Folder()
            private_folder.name = '%s Private' % group.name
            private_folder.notes = 'This folder is private to the %s group' % group.name
            private_folder.save()

            # Give users in this group read and write access to it
            private_folder.setPermissions(group, Actions.WRITE)
            private_folder.save()

            # Now we need to create the public folder for this group
            public_folder = Folder()
            public_folder.name = '%s Public' % group.name
            public_folder.notes = 'This folder is publically viewable and writable memebers of the %s group' % group.name
            public_folder.save()

            # Give any user the ability to read this folder
            anyuser = Group.objects.get(name="anyuser")
            public_folder.setPermissions(anyuser, Actions.READ)

            # Give this group read and write access
            public_folder.setPermissions(group, Actions.WRITE)
            public_folder.save()

            return (group, group_profile, public_folder, private_folder)

        return group