Example #1
0
    def post(self):

        form = self.form
        U = self.U

        if form.validate():

            effect_date = form.effect_date.data
            expired_date = form.expired_date.data

            for t, s in [
                ( Resource.T_CPU, form.cpu.data ),
                ( Resource.T_MEMORY, form.memory.data ),
                ( Resource.T_STORAGE, form.storage.data ),
                ( Resource.T_INSTANCE, form.instance.data ) ]:

                r = Resource( user = U, rtype = t, size = s,
                              effect_date = effect_date,
                              expired_date = expired_date )

                self.db.add(r)

            self.db.commit()

            U.profile.update_resource_total()
            self.db.commit()

            # count be choices, email notice
            resource_mail_notice(self, U)

            url = self.reverse_url('admin:user:view')
            url += '?id=%s' % U.id
            return self.redirect( url )

        self.render()
Example #2
0
    def post(self):

        form = self.form
        user = self.user

        if form.validate():
            new = Resource( user = user,
                            rtype = form.type.data,
                            size = form.size.data,
                            effect_date = form.effect_date.data,
                            expired_date = form.expired_date.data )
            self.db.add( new )
            self.db.commit()

            user.profile.update_resource_total()
            self.db.commit()

            # count be choices, email notice
            resource_mail_notice(self, user)

            url = self.reverse_url('admin:user:view')
            url += '?id=%s' % user.id
            return self.redirect( url )

        self.render()
Example #3
0
    def post(self):

        form = self.form

        if form.validate():

            effect_date = form.effect_date.data
            expired_date = form.expired_date.data

            for U in self.db.query(User):
                if U.resources: continue  # hacker
                logging.warn('add resource for %s:%s' % (U.id, U.username))
                for t, s in [(Resource.T_CPU, form.cpu.data),
                             (Resource.T_MEMORY, form.memory.data),
                             (Resource.T_STORAGE, form.storage.data),
                             (Resource.T_INSTANCE, form.instance.data)]:

                    r = Resource(user=U,
                                 rtype=t,
                                 size=s,
                                 effect_date=effect_date,
                                 expired_date=expired_date)

                    self.db.add(r)

                self.db.commit()

                # count be choices, email notice
                resource_mail_notice(self, U)

            url = self.reverse_url('admin:user')
            return self.redirect(url)

        self.render()
Example #4
0
    def post(self):

        form = self.form
        U = self.U

        if form.validate():

            effect_date = form.effect_date.data
            expired_date = form.expired_date.data

            for t, s in [(Resource.T_CPU, form.cpu.data),
                         (Resource.T_MEMORY, form.memory.data),
                         (Resource.T_STORAGE, form.storage.data),
                         (Resource.T_INSTANCE, form.instance.data)]:

                r = Resource(user=U,
                             rtype=t,
                             size=s,
                             effect_date=effect_date,
                             expired_date=expired_date)

                self.db.add(r)

            self.db.commit()

            # count be choices, email notice
            resource_mail_notice(self, U)

            url = self.reverse_url('admin:user:view')
            url += '?id=%s' % U.id
            return self.redirect(url)

        self.render()
Example #5
0
    def post(self):

        form = self.form

        if form.validate():

            effect_date = form.effect_date.data
            expired_date = form.expired_date.data

            for U in self.db.query(User):
                if U.resources: continue # hacker
                logging.warn('add resource for %s:%s' % (U.id, U.username))
                for t, s in [
                    ( Resource.T_CPU, form.cpu.data ),
                    ( Resource.T_MEMORY, form.memory.data ),
                    ( Resource.T_STORAGE, form.storage.data ),
                    ( Resource.T_INSTANCE, form.instance.data ) ]:

                    r = Resource( user = U, rtype = t, size = s,
                                  effect_date = effect_date,
                                  expired_date = expired_date )

                    self.db.add(r)

                self.db.commit()

                # count be choices, email notice
                resource_mail_notice(self, U)


            url = self.reverse_url('admin:user')
            return self.redirect( url )

        self.render()
Example #6
0
    def post(self):

        form = self.form
        user = self.user

        if form.validate():
            new = Resource(user=user,
                           rtype=form.type.data,
                           size=form.size.data,
                           effect_date=form.effect_date.data,
                           expired_date=form.expired_date.data)
            self.db.add(new)
            self.db.commit()

            # count be choices, email notice
            resource_mail_notice(self, user)

            url = self.reverse_url('admin:user:view')
            url += '?id=%s' % user.id
            return self.redirect(url)

        self.render()