Ejemplo n.º 1
0
    def create(self):
        """POST /users: Create a new item"""
        # url('users')
        c.default_extern_type = auth_rhodecode.RhodeCodeAuthPlugin.name
        user_model = UserModel()
        user_form = UserForm()()
        try:
            form_result = user_form.to_python(dict(request.POST))
            user = user_model.create(form_result)
            Session().flush()
            username = form_result['username']
            action_logger(c.rhodecode_user, 'admin_created_user:%s' % username,
                          None, self.ip_addr, self.sa)

            user_link = h.link_to(h.escape(username),
                                  url('edit_user', user_id=user.user_id))
            h.flash(h.literal(
                _('Created user %(user_link)s') % {'user_link': user_link}),
                    category='success')
            Session().commit()
        except formencode.Invalid as errors:
            return htmlfill.render(render('admin/users/user_add.html'),
                                   defaults=errors.value,
                                   errors=errors.error_dict or {},
                                   prefix_error=False,
                                   encoding="UTF-8",
                                   force_defaults=False)
        except UserCreationError as e:
            h.flash(e, 'error')
        except Exception:
            log.exception("Exception creation of user")
            h.flash(_('Error occurred during creation of user %s') %
                    request.POST.get('username'),
                    category='error')
        return redirect(url('users'))
Ejemplo n.º 2
0
    def create(self):
        """POST /users: Create a new item"""
        # url('users')

        user_model = UserModel()
        user_form = UserForm()()
        try:
            form_result = user_form.to_python(dict(request.POST))
            user_model.create(form_result)
            h.flash(_('created user %s') % form_result['username'],
                    category='success')
            Session.commit()
            #action_logger(self.rhodecode_user, 'new_user', '', '', self.sa)
        except formencode.Invalid, errors:
            return htmlfill.render(render('admin/users/user_add.html'),
                                   defaults=errors.value,
                                   errors=errors.error_dict or {},
                                   prefix_error=False,
                                   encoding="UTF-8")
Ejemplo n.º 3
0
    def create(self):
        """POST /users: Create a new item"""
        # url('users')

        user_model = UserModel()
        login_form = UserForm()()
        try:
            form_result = login_form.to_python(dict(request.POST))
            user_model.create(form_result)
            h.flash(_('created user %s') % form_result['username'],
                    category='success')
            #action_logger(self.rhodecode_user, 'new_user', '', '', self.sa)
        except formencode.Invalid, errors:
            return htmlfill.render(
                render('admin/users/user_add.html'),
                defaults=errors.value,
                errors=errors.error_dict or {},
                prefix_error=False,
                encoding="UTF-8")
Ejemplo n.º 4
0
    def create(self):
        """POST /users: Create a new item"""
        # url('users')

        user_model = UserModel()
        user_form = UserForm()()
        try:
            form_result = user_form.to_python(dict(request.POST))
            user_model.create(form_result)
            usr = form_result['username']
            action_logger(self.rhodecode_user, 'admin_created_user:%s' % usr,
                          None, self.ip_addr, self.sa)
            h.flash(_('Created user %s') % usr,
                    category='success')
            Session().commit()
        except formencode.Invalid, errors:
            return htmlfill.render(
                render('admin/users/user_add.html'),
                defaults=errors.value,
                errors=errors.error_dict or {},
                prefix_error=False,
                encoding="UTF-8")