def handle(self, *groupnames, **options):
        self.all = options.get('all', False)

        if self.all:
            print "Enabling sharing for all groups..."
            enable_sharing()
            gs = Group.objects.all()
            for g in gs:
                enable_sharing(g)
                print " [DONE]", g.name
            return

        if len(groupnames) > 0:
            print "Enabling sharing for %s groups.." % len(groupnames)
            enable_sharing()
            for gname in groupnames:
                try:
                    g = Group.objects.get(name=gname)
                    enable_sharing(g)
                    print " [DONE]", gname
                except Exception as e:
                    print " [FAILED]", gname
                    print "  ",e
            return 

        enable_sharing()
        print """
Exemple #2
0
    def create(self, name, owner, open=False, blurb='', image=''):
        """Creates a new map group with the specified options, owned by the
        specified user.

        @returns a tuple of (group, member)
        """
        mg = MapGroup()
        mg.name = name
        mg.blurb = blurb
        mg.owner = owner
        mg.is_open = open
        mg.image = image

        # Introduce a dependency on Groups so the Madrona feature sharing
        # will continue to work.
        name = mg._permission_group_name()
        pg = Group.objects.create(name=name)
        enable_sharing(pg)

        mg.permission_group = pg
        mg.save()

        # Add the owner to the new perm group
        owner.groups.add(pg)

        member = MapGroupMember()
        member.user = owner
        member.is_manager = True
        member.map_group = mg
        member.save()

        return mg, member
    def create(self, name, owner, open=False, blurb='', image=''):
        """Creates a new map group with the specified options, owned by the
        specified user.

        @returns a tuple of (group, member)
        """
        mg = MapGroup()
        mg.name = name
        mg.blurb = blurb
        mg.owner = owner
        mg.is_open = open
        mg.image = image

        # Introduce a dependency on Groups so the Madrona feature sharing
        # will continue to work.
        name = mg._permission_group_name()
        pg = Group.objects.create(name=name)
        enable_sharing(pg)

        mg.permission_group = pg
        mg.save()

        # Add the owner to the new perm group
        owner.groups.add(pg)

        member = MapGroupMember()
        member.user = owner
        member.is_manager = True
        member.map_group = mg
        member.save()

        return mg, member
    def handle(self, *groupnames, **options):
        self.all = options.get('all', False)

        if self.all:
            print("Enabling sharing for all groups...")
            enable_sharing()
            gs = Group.objects.all()
            for g in gs:
                enable_sharing(g)
                print(" [DONE]", g.name)
            return

        if len(groupnames) > 0:
            print("Enabling sharing for %s groups.." % len(groupnames))
            enable_sharing()
            for gname in groupnames:
                try:
                    g = Group.objects.get(name=gname)
                    enable_sharing(g)
                    print(" [DONE]", gname)
                except Exception as e:
                    print(" [FAILED]", gname)
                    print("  ", e)
            return

        enable_sharing()
        print("""
The site is now configured to allow sharing.
For a group to share features, you must grant this permission explictly to group:

    $ python manage.py enable_sharing GroupName "Group Name with Spaces"

OR to grant sharing permissions to all groups:

    $ python manage.py enable_sharing --all
""")