예제 #1
0
    def post(self):
        form = GroupCreateForm(self.request.arguments)
        if not form.validate():
            return self.render(
                "group-create.html", form=form,
                alerts=self.get_form_alerts(form.errors)
            )

        user = self.get_current_user()

        group = Group(
            groupname=form.data["groupname"],
            description=form.data["description"],
            canjoin=form.data["canjoin"]
        )
        try:
            group.add(self.session)
            self.session.flush()
        except IntegrityError:
            self.session.rollback()
            form.groupname.errors.append(
                "{} already exists".format(form.data["groupname"])
            )
            return self.render(
                "group-create.html", form=form,
                alerts=self.get_form_alerts(form.errors)
            )

        group.add_member(user, user, "Group Creator", "actioned", None, form.data["creatorrole"])
        self.session.commit()

        AuditLog.log(self.session, self.current_user.id, 'create_group',
                     'Created new group.', on_group_id=group.id)

        return self.redirect("/groups/{}?refresh=yes".format(group.name))
예제 #2
0
    def post(self, *args: Any, **kwargs: Any) -> None:
        form = GroupCreateForm(self.request.arguments)
        if not form.validate():
            return self.render(
                "group-create.html", form=form, alerts=self.get_form_alerts(form.errors)
            )

        if "@" in form.data["groupname"]:
            form.groupname.errors.append("Group names cannot contain @")
            return self.render(
                "group-create.html", form=form, alerts=self.get_form_alerts(form.errors)
            )

        group = Group(
            groupname=form.data["groupname"],
            description=form.data["description"],
            canjoin=form.data["canjoin"],
            auto_expire=form.data["auto_expire"],
            require_clickthru_tojoin=form.data["require_clickthru_tojoin"],
        )
        try:
            group.add(self.session)
            self.session.flush()
        except IntegrityError:
            self.session.rollback()
            form.groupname.errors.append("{} already exists".format(form.data["groupname"]))
            return self.render(
                "group-create.html", form=form, alerts=self.get_form_alerts(form.errors)
            )

        group.add_member(
            self.current_user,
            self.current_user,
            "Group Creator",
            "actioned",
            None,
            form.data["creatorrole"],
        )
        self.session.commit()

        AuditLog.log(
            self.session,
            self.current_user.id,
            "create_group",
            "Created new group.",
            on_group_id=group.id,
        )

        return self.redirect("/groups/{}?refresh=yes".format(group.name))
예제 #3
0
    def post(self, *args, **kwargs):
        # type: (*Any, **Any) -> None
        form = GroupCreateForm(self.request.arguments)
        if not form.validate():
            return self.render(
                "group-create.html", form=form, alerts=self.get_form_alerts(form.errors)
            )

        group = Group(
            groupname=form.data["groupname"],
            description=form.data["description"],
            canjoin=form.data["canjoin"],
            auto_expire=form.data["auto_expire"],
            require_clickthru_tojoin=form.data["require_clickthru_tojoin"],
        )
        try:
            group.add(self.session)
            self.session.flush()
        except IntegrityError:
            self.session.rollback()
            form.groupname.errors.append("{} already exists".format(form.data["groupname"]))
            return self.render(
                "group-create.html", form=form, alerts=self.get_form_alerts(form.errors)
            )

        group.add_member(
            self.current_user,
            self.current_user,
            "Group Creator",
            "actioned",
            None,
            form.data["creatorrole"],
        )
        self.session.commit()

        AuditLog.log(
            self.session,
            self.current_user.id,
            "create_group",
            "Created new group.",
            on_group_id=group.id,
        )

        return self.redirect("/groups/{}?refresh=yes".format(group.name))
예제 #4
0
    def post(self):
        form = GroupCreateForm(self.request.arguments)
        if not form.validate():
            return self.render(
                "group-create.html", form=form,
                alerts=self.get_form_alerts(form.errors)
            )

        user = self.get_current_user()

        group = Group(
            groupname=form.data["groupname"],
            description=form.data["description"],
            canjoin=form.data["canjoin"],
            auto_expire=form.data["auto_expire"],
        )
        try:
            group.add(self.session)
            self.session.flush()
        except IntegrityError:
            self.session.rollback()
            form.groupname.errors.append(
                "{} already exists".format(form.data["groupname"])
            )
            return self.render(
                "group-create.html", form=form,
                alerts=self.get_form_alerts(form.errors)
            )

        group.add_member(user, user, "Group Creator", "actioned", None, form.data["creatorrole"])
        self.session.commit()

        AuditLog.log(self.session, self.current_user.id, 'create_group',
                     'Created new group.', on_group_id=group.id)

        return self.redirect("/groups/{}?refresh=yes".format(group.name))