Пример #1
0
    def nuevo(self, id_fase, **kw):
        """Despliega el formulario para añadir una linea base a la fase"""
	fase=DBSession.query(Fase).get(id_fase)
	#Comprobación de si el estado de la fase se encuentra en Con Lineas Bases
	if fase.relacion_estado_fase.nombre_estado=='Con Lineas Bases':
		flash(_("Todos los items de esta fase ya se encuentran en una Linea Base Aprobada"), 'warning')
                redirect("/admin/linea_base/listado_linea_bases",id_proyecto=fase.id_proyecto, id_fase=id_fase)	    
	tipo_items=DBSession.query(TipoItem).filter_by(id_fase=id_fase)
	itemsDeFaseActual = []
	for tipo_item in tipo_items:
		itemsTipoItem = DBSession.query(Item).filter_by(id_tipo_item=tipo_item.id_tipo_item).filter_by(vivo=True)
		for itemTipoItem in itemsTipoItem:
			itemsDeFaseActual.append(itemTipoItem)
	contador_items_en_fase_actual = 0
	for item in itemsDeFaseActual:
		contador_items_en_fase_actual = contador_items_en_fase_actual + 1
	#Comprobación de si existen items cargados para la fase actual
	if contador_items_en_fase_actual == 0:
		flash(_("Aun no existen items cargados para esta fase"), 'warning')
                redirect("/admin/linea_base/listado_linea_bases",id_proyecto=fase.id_proyecto, id_fase=id_fase)		
        kw['id_estado']= 'Desarrollo'
        kw['id_fase']= id_fase
	kw['version']= '1'
	tmpl_context.form = crear_linea_base_form
        return dict(nombre_modelo='LineaBase', id_proyecto=fase.id_proyecto, id_fase=id_fase, page='nuevo', value=kw)
Пример #2
0
    def add_transaction(self, **values):
        values["validation_status"] = request.validation
        flash(values["validation_status"])

        user = request.identity["user"]

        transaction = Transaction(user=user)
        transaction.amount = float(values["amount"])
        transaction.date = RelativeDatetime.str2date(values["datetime"])

        if values["foreign-currency-amount"]:
            transaction.foreignCurrencyAmount = float(values["foreign-currency-amount"])
            transaction.foreignCurrency = "EUR"

        income_tags_names = Tag.get_names_from_str(values["income-tags"])
        if income_tags_names:
            transaction.incomeTagGroup = Tag.new_from_name_list(income_tags_names)

        expense_tags_names = Tag.get_names_from_str(values["expense-tags"])
        if expense_tags_names:
            transaction.expenseTagGroup = Tag.new_from_name_list(income_tags_names)

        db.add(transaction)
        db.flush()

        redirect("/transaction")
Пример #3
0
 def post_logout(self, came_from=lurl('/')):
     """
     Redirect the user to the initially requested page on logout and say
     goodbye as well.
     """
     flash(_('Successfully logged out. We hope to see you soon!'))
     redirect(came_from)
Пример #4
0
    def listadoItemsParaAsignaraLineaBase(self, id_proyecto, id_fase, id_linea_base, page=1):
        """Metodo para listar todos los items a asignar a la linea base"""
	lineabase=DBSession.query(LineaBase).get(id_linea_base)
        if lineabase.estado=='Aprobado':
		flash(_("La Linea Base ya se encuentra aprobada"), 'warning')
                redirect("/admin/linea_base/listado_linea_bases",id_proyecto=id_proyecto, id_fase=id_fase)
	linea_bases=DBSession.query(LineaBase).filter_by(id_fase=id_fase)
	itemsenLineaBase = []
	for linea_base in linea_bases:
		itemsLineaBase = linea_base.items
		for itemLineaBase in itemsLineaBase:
			itemsenLineaBase.append(itemLineaBase)
	#items Contiene todos los items que se encuentran en la fase actual
	tipo_items=DBSession.query(TipoItem).filter_by(id_fase=id_fase)
	itemsDeFaseActual = []
	for tipo_item in tipo_items:
		itemsTipoItem = DBSession.query(Item).filter_by(id_tipo_item=tipo_item.id_tipo_item).filter_by(vivo=True).filter_by(estado='Aprobado').order_by(Item.id_item)
		for itemTipoItem in itemsTipoItem:
			itemsDeFaseActual.append(itemTipoItem)
	items=itemsDeFaseActual
        if itemsenLineaBase != None: 
	   for item in itemsenLineaBase:
               if items.count(item) >= 1:
                  items.remove(item)
        currentPage = paginate.Page(items, page)
        return dict(items=currentPage.items, page='listadoItemsParaAsignaraLineaBase', id_proyecto=id_proyecto, 
                    id_fase=id_fase, id_linea_base=id_linea_base, currentPage=currentPage)
Пример #5
0
 def delete(self, id, **kw):
    ''' Delete department from DB
    '''
    log.info('delete ' + kw['_id'])
    DBSession.delete(DBSession.query(Department).get(kw['_id']))
    flash(u'Service supprimé', 'notice')
    redirect('/departments/')
Пример #6
0
    def delete_assignment(self, **data):

        user_name = request.identity['repoze.who.userid']
        user_id = DBSession.query(model.User.user_id).filter(model.User.user_name==user_name).first().user_id

        #Report if not user who is logged in
        if DBSession.query(model.License).join(model.Assignment).filter(model.Assignment.id==data['id'], model.License.user_id==user_id).count() < 1:
            flash(('This incident has been reported'), 'error')
            redirect('/manage')

        locked = DBSession.query(model.Assignment.locked).filter(model.Assignment.id==data['id']).first().locked

        if locked == True:
            flash(_('Cannot delete. Assignment already redeemed.'), 'warning')
        else:
            license = DBSession.query(model.License).join(model.Assignment).filter(model.Assignment.id==data['id']).first()

            license.available = license.available + DBSession.query(model.Assignment).filter(model.Assignment.id==data['id']).first().count

            q = DBSession.query(model.Assignment).filter(model.Assignment.id==data['id']).delete()

            DBSession.flush()

            flash('Assignment deleted')

        redirect('/manage')
Пример #7
0
    def assign_license(self, **kwargs):

        user_name = request.identity['repoze.who.userid']
        user_id = DBSession.query(model.User.user_id).filter(model.User.user_name==user_name).first().user_id

        #Report if computer or license don't belong to user who is logged in and available > 0
        if DBSession.query(model.Computer).filter(model.Computer.id==kwargs['computer'], model.Computer.user_id==user_id).count() < 1  or DBSession.query(model.License).filter(model.License.id==kwargs['license'], model.License.user_id==user_id).count() < 1 or DBSession.query(model.License.available).filter(model.License.id==kwargs['license'], model.License.user_id==user_id).first().available < 1:
            flash(('This incident has been reported'), 'error')
            redirect('/manage')

        a = model.Assignment()
        a.user_id = user_id
        a.license_id = kwargs['license']
        a.computer_id = kwargs['computer']
        a.count = 1
        a.locked = False

        model.DBSession.add(a)

        license = DBSession.query(model.License).filter(model.License.id==a.license_id).first()
        license.available = license.available - a.count


        model.DBSession.flush()

        flash("Assignment added.")
        redirect('/manage')
Пример #8
0
	def delete(self, id_fase ,id, show=True, **kw):
		"""
		@type  id_fase : Integer
		@param id_fase : Identificador del Rol

		@type  id : Integer
		@param id : Identificador del usuario a desvincular.

		@type  show : Boolean
		@param show : Indica si se despelgara el mensaje al culminar la operacion.

		@type  kw : Hash
		@param kw : Keywords
		"""
		fase = fase_util.get_current()
		list = DBSession.query(UsuarioPermisoFase).\
				filter(UsuarioPermisoFase.usuario_id == id).\
				filter(UsuarioPermisoFase.fase_id == id_fase)

		for element in list :
			DBSession.delete(element)
		"""
		Si es false no muestra el mensaje de sobre la operacion, esto es debido
		que este metodo es reutilizado a la hora de eliminar a un usuario del
		proyecto
		"""
		if show :
			flash("El usuario '"+ str(id) +"' ha sido desvinculado de la fase.")
			redirect("/miproyecto/fase/get_all/"+ str(id_fase))
Пример #9
0
	def delete(self, proyecto_id ,id, **kw):
		"""
		@type  proyecto_id : Integer
		@param proyecto_id : Identificador del proyecto

		@type  id : Integer
		@param id : Identificador del usuario a desvincular.

		@type  kw : Hash
		@param kw : Keywords
		"""
		#se obtienen las relaciones del usuario sobre las fases del proyecto
		list = DBSession.query(UsuarioPermisoFase).\
				filter(UsuarioPermisoFase.usuario_id == id).\
				filter(Fase.proyecto == proyecto_id).\
				filter(UsuarioPermisoFase.fase_id == Fase.id_fase)
		#Se eliminan las relaciones del usuario con las fases
		for element in list :
			DBSession.delete(element)
		#Se obtienen los roles del usuario en el proyecto
		list = DBSession.query(RolUsuario).\
				  filter(RolUsuario.usuario_id == id).\
				  filter(RolUsuario.rol_id == RolPermisoProyecto.rol_id).\
				  filter(RolPermisoProyecto.proyecto_id == proyecto_id)
		#Se eliminan los roles del usuario sobre el proyecto
		for element in list :
			DBSession.delete(element)

		flash("El usuario '"+ str(id) +"' ha sido desvinculado del proyecto.")
		redirect("/miproyecto/ver/"+str(proyecto_id))
Пример #10
0
    def set_exfeed(self, new_exfeed=None, **kw):
        exfeed_val = kw.get('exfeed', [])
        if type(exfeed_val) == unicode:
            tmp_exfeed_list = []
            tmp_exfeed_list.append(exfeed_val)
        else:
            tmp_exfeed_list = exfeed_val

        if new_exfeed is not None and new_exfeed != '':
            tmp_exfeed_list.append(new_exfeed)

        exfeed_list = []
        invalid_list = []
        v = validators.URL()
        for link in tmp_exfeed_list:
            try:
                v.to_python(link)
                exfeed_list.append(link)
            except formencode.api.Invalid:
                invalid_list.append(link)

        self.app.external_feeds_list = exfeed_list
        flash('External feeds updated')
        if len(invalid_list) > 0:
            flash('Invalid link(s): %s' %
                  ','.join(link for link in invalid_list), 'error')

        redirect(request.referer)
Пример #11
0
	def post(self, id, args={}, **kw):
		"""
		Evento invocado luego de un evento post en el form de editar
		ecargado de asociar a los usuarios con las fases y sus permisos.

		@type  id : Integer
		@param id : Identificador de la fase.

		@type  args : Hash
		@param args : Argumentos de template

		@type  kw : Hash
		@param kw : Keywords

		"""
		fase = fase_util.get_current()
		_usuarios = usuario_util.get_usuarios_by_fase(fase.id_fase)
		for usuario in _usuarios:
			self.delete(fase.id_fase ,usuario.usuario_id, False)

		usuarios = []
		for key in kw:
			usuarios.append(key)

		list = DBSession.query(Usuario).\
				filter(Usuario.user_name.in_(usuarios)).all()
		for usuario in list:
			usuario_util.asociar_usuario_fase(usuario.usuario_id, fase.id_fase)

		redirect("/miproyecto/fase/get_all/" + str(fase.id_fase) )
Пример #12
0
 def revert(self, version, **kw):
     require_access(self.post, 'write')
     orig = self._get_version(version)
     if orig:
         self.post.text = orig.text
     self.post.commit()
     redirect('.')
Пример #13
0
 def set_options(self, show_discussion=False, allow_email_posting=False):
     self.app.config.options[
         'show_discussion'] = show_discussion and True or False
     self.app.config.options[
         'AllowEmailPosting'] = allow_email_posting and True or False
     flash('Blog options updated')
     redirect(request.referer)
Пример #14
0
    def tracking_register(self, came_from='/tracking/info'):
        if not self.user.is_writable(request.identity):
            raise HTTPForbidden

        self.user.generate_tracking_key()

        redirect(came_from)
Пример #15
0
 def save(self, **kw):
     require_access(c.app, 'write')
     rate_limit()
     post = BM.BlogPost.new(**kw)
     g.spam_checker.check(kw['title'] + u'\n' + kw['text'], artifact=post,
                          user=c.user, content_type='blog-post')
     redirect(h.really_unicode(post.url()).encode('utf-8'))
Пример #16
0
 def do_request_merge(self, **kw):
     try:
         kw = self.mr_widget.to_python(kw)
     except formencode.Invalid:
         # trigger error_handler directly
         return self.request_merge(**kw)
     downstream = dict(
         project_id=c.project._id,
         mount_point=c.app.config.options.mount_point,
         commit_id=c.app.repo.commit(kw['source_branch'])._id)
     with c.app.repo.push_upstream_context():
         mr = M.MergeRequest.upsert(
             downstream=downstream,
             target_branch=kw['target_branch'],
             source_branch=kw['source_branch'],
             summary=kw['summary'],
             description=kw['description'])
         if kw.get('subscribe'):
             mr.subscribe(user=c.user)
         M.Notification.post(
             mr, 'merge_request',
             subject=mr.email_subject,
             message_id=mr.message_id(),
         )
         t = M.Thread.new(
             discussion_id=c.app.config.discussion_id,
             ref_id=mr.index_id(),
         )
         session(t).flush()
         g.director.create_activity(c.user, 'created', mr,
                                    related_nodes=[c.project], tags=['merge-request'])
         redirect(mr.url())
Пример #17
0
    def save(self, email_address, display_name, club,
             tracking_delay=0, unit_preset=1,
             distance_unit=1, speed_unit=1,
             lift_unit=0, altitude_unit=0,
             eye_candy=False, **kwargs):
        if not self.user.is_writable(request.identity):
            raise HTTPForbidden

        self.user.email_address = email_address
        self.user.display_name = display_name
        if not club:
            club = None
        self.user.club_id = club
        self.user.tracking_delay = tracking_delay

        unit_preset = int(unit_preset)
        if unit_preset == 0:
            self.user.distance_unit = distance_unit
            self.user.speed_unit = speed_unit
            self.user.lift_unit = lift_unit
            self.user.altitude_unit = altitude_unit
        else:
            self.user.unit_preset = unit_preset

        self.user.eye_candy = eye_candy
        DBSession.flush()

        redirect('.')
Пример #18
0
    def post_tipo_item(self, nombre_tipo_item, codigo_tipo_item, descripcion, campo, valor):
        tipo_item = Tipo_Item(
            nombre_tipo_item=nombre_tipo_item, codigo_tipo_item=codigo_tipo_item, descripcion=descripcion
        )

        DBSession.add(tipo_item)

        if campo is not None:
            if not isinstance(campo, list):
                campo = [campo]

        if valor is not None:
            if not isinstance(valor, list):
                valor = [valor]

        indice = 0
        id_tipo = Tipo_Item.get_ultimo_id()
        for c in campo:
            if len(c) > 0:
                camp = Tipo_Campos(id_tipo_item=id_tipo, nombre_campo=c, valor_campo=valor[indice])
                DBSession.add(camp)
            indice += 1

        flash("Tipo Item Agregado!")
        redirect("/tipo_item/tipo_item")
Пример #19
0
 def refresh(self, **kw):
     allura.tasks.repo_tasks.refresh.post()
     if request.referer:
         flash('Repository is being refreshed')
         redirect(request.referer or '/')
     else:
         return '%r refresh queued.\n' % c.app.repo
Пример #20
0
Файл: rol.py Проект: mbaez/SAP
	def post(self, args={}, **kw):
		"""
		Evento invocado luego de un evento post en el form de crear
		ecargado de persistir las nuevas instancias.

		@type  args : Hash
		@param args : Argumentos de template

		@type  kw : Hash
		@param kw : Keywords

		"""

		del kw['sprox_id']
		rol = Rol()
		rol.codigo = kw['codigo']
		rol.nombre = kw['nombre']
		rol.descripcion = kw['descripcion']

		for permiso in kw['permisos'] :
			rol.permisos.append(DBSession.query(Permiso).get(permiso))

		DBSession.add(rol)
		flash("El rol ha sido creado correctamente.")
		redirect("/administracion/rol/get_all")
Пример #21
0
    def put(self, id_tipo_item, nombre_tipo_item, codigo_tipo_item, descripcion, campo, valor, **kw):

        if id_tipo_item is not None:
            id_tipo_item = int(id_tipo_item)

        tipo_item = Tipo_Item.get_tipo_item_by_id(id_tipo_item)
        campos2 = Tipo_Campos.get_campos_by_tipo_item(tipo_item.id_tipo_item)

        for cam in campos2:
            Tipo_Campos.borrar_by_id(cam.id_tipo_campos)
            DBSession.flush()

        tipo_item.nombre_tipo_item = nombre_tipo_item
        tipo_item.descripcion = descripcion
        tipo_item.codigo_tipo_item = codigo_tipo_item

        if campo is not None:
            if not isinstance(campo, list):
                campo = [campo]

        if valor is not None:
            if not isinstance(valor, list):
                valor = [valor]

        indice = 0

        for c in campo:
            if len(c) > 0:
                camp = Tipo_Campos(id_tipo_item=id_tipo_item, nombre_campo=c, valor_campo=valor[indice])
                DBSession.add(camp)
            indice += 1

        DBSession.flush()
        flash("Tipo de Item modificada!")
        redirect("/tipo_item/tipo_item")
Пример #22
0
 def update(self, card=None, **kw):
     permissions = self._index_permissions()
     old_permissions = dict(permissions)
     for args in card:
         perm = args['id']
         new_group_ids = args.get('new', [])
         group_ids = args.get('value', [])
         if isinstance(new_group_ids, basestring):
             new_group_ids = [ new_group_ids ]
         if isinstance(group_ids, basestring):
             group_ids = [ group_ids ]
         # make sure the admin group has the admin permission
         if perm == 'admin':
             if c.project.is_root:
                 pid = c.project._id
             else:
                 pid = c.project.parent_id
             admin_group_id = str(M.ProjectRole.query.get(project_id=pid, name='Admin')._id)
             if admin_group_id not in group_ids + new_group_ids:
                 flash('You cannot remove the admin group from the admin permission.','warning')
                 group_ids.append(admin_group_id)
         permissions[perm] = []
         role_ids = map(ObjectId, group_ids + new_group_ids)
         permissions[perm] = role_ids
     c.project.acl = []
     for perm, role_ids in permissions.iteritems():
         role_names = lambda ids: ','.join(sorted(
                 pr.name for pr in M.ProjectRole.query.find(dict(_id={'$in':ids}))))
         old_role_ids = old_permissions.get(perm, [])
         if old_role_ids != role_ids:
             M.AuditLog.log('updated "%s" permissions: "%s" => "%s"',
                            perm,role_names(old_role_ids), role_names(role_ids))
         c.project.acl += [M.ACE.allow(rid, perm) for rid in role_ids]
     g.post_event('project_updated')
     redirect('.')
Пример #23
0
 def clone(self,
           repo_type=None, source_url=None,
           mount_point=None, mount_label=None,
           **kw):
     require_access(c.project, 'admin')
     if repo_type is None:
         return (
             '<form method="get">'
             '<input name="repo_type" value="Git">'
             '<input name="source_url">'
             '<input type="submit">'
             '</form>')
     for ep in pkg_resources.iter_entry_points('allura', repo_type):
         break
     if ep is None or source_url is None:
         raise exc.HTTPNotFound
     h.log_action(log, 'install tool').info(
         'clone repo from %s', source_url,
         meta=dict(tool_type=repo_type, mount_point=mount_point, mount_label=mount_label))
     c.project.install_app(
         repo_type,
         mount_point=mount_point,
         mount_label=mount_label,
         init_from_url=source_url)
     M.AuditLog.log('Create repo as clone')
     redirect('tools')
Пример #24
0
def check_access():
   '''Check access rights / group: admin=full access, boss=users from same department, user.
   Returns SA Query object for selected CDRs
   '''

   if in_any_group('admin', 'APPELS'):
      cdrs = DBSession.query(CDR)

   elif in_group('CDS'):
      # Find list of phones from the user's list of phones
      # user_phones -> departments -> phones
      phones = []
      for p in request.identity['user'].phone:
         log.info('CDS phone %s -> department %s' % (p, p.department))
      for d in [d.department for d in request.identity['user'].phone]:
         log.info('CDS department <%s>' % (d))
         for p in d.phones:
            phones.append(p)
      src = [prefix_src + p.exten for p in phones]
      dst = [p.exten for p in phones]
      cdrs = DBSession.query(CDR).filter( (CDR.src.in_(src)) | (CDR.dst.in_(dst)) )
      log.info('CDS phone <%s> -> source <%s>, destination <%s>' % (
         request.identity['user'].phone, src, dst))


   elif in_group('utilisateurs'):
      src = [prefix_src + p.exten for p in request.identity['user'].phone]
      dst = [p.exten for p in request.identity['user'].phone]
      cdrs = DBSession.query(CDR).filter( (CDR.src.in_(src)) | (CDR.dst.in_(dst)) )

   else:
      flash(u'Accès interdit')
      redirect('/')

   return cdrs
Пример #25
0
 def delete(self, fileid):
     try:
         userfile = DBSession.query(UserFile).filter_by(id=fileid).one()
     except:
         return redirect("/")
     DBSession.delete(userfile)
     return redirect("/")
Пример #26
0
 def attach(self, file_info=None):
     if not self.page:
         raise exc.HTTPNotFound
     require_access(self.page, 'edit')
     if hasattr(file_info, 'file'):
         self.page.attach(file_info.filename, file_info.file, content_type=file_info.type)
     redirect(request.referer)
Пример #27
0
 def set_home(self, new_home):
     self.app.root_page_name = new_home
     self.app.upsert_root(new_home)
     flash('Home updated')
     mount_base = c.project.url()+self.app.config.options.mount_point+'/'
     url = h.really_unicode(mount_base).encode('utf-8') + h.really_unicode(new_home).encode('utf-8')+'/'
     redirect(url)
Пример #28
0
 def delete_screenshot(self, id=None, **kw):
     require_access(c.project, 'update')
     if id is not None and id != '':
         M.AuditLog.log('remove screenshot')
         M.ProjectFile.query.remove(dict(project_id=c.project._id, _id=ObjectId(id)))
         g.post_event('project_updated')
     redirect('screenshots')
Пример #29
0
 def _lookup(self, pname, *remainder):
     page = WM.Page.query.get(
         app_config_id=c.app.config._id, title=pname)
     if page:
         redirect(page.url())
     else:
         raise exc.HTTPNotFound
Пример #30
0
Файл: rol.py Проект: mbaez/SAP
	def put(self, args={}, **kw):
		"""
		Evento invocado luego de un evento post en el form de editar
		ecargado de persistir las modificaciones de las instancias.

		@type  args : Hash
		@param args : Argumentos de template

		@type  kw : Hash
		@param kw : Keywords

		"""
		del kw['sprox_id']
		rol = DBSession.query(Rol).get(int(kw['rol_id']))
		rol.nombre = kw['nombre']
		rol.codigo = kw['codigo']
		rol.descripcion = kw['descripcion']
		rol.is_template = kw['is_template']
		rol.permisos = []

		for permiso_id in kw['permisos'] :
			rol.permisos.append(DBSession.query(Permiso).get(permiso_id))

		DBSession.merge(rol)
		flash("El rol '"+rol.nombre+"' ha sido modificado correctamente.")
		redirect("/administracion/rol/get_all")
Пример #31
0
    def update(self,
               name=None,
               short_description=None,
               summary='',
               icon=None,
               category=None,
               external_homepage='',
               support_page='',
               support_page_url='',
               removal='',
               moved_to_url='',
               export_controlled=False,
               export_control_type=None,
               tracking_id='',
               **kw):
        require_access(c.project, 'update')

        if removal != c.project.removal:
            M.AuditLog.log('change project removal status to %s', removal)
            h.log_action(log, 'change project removal status').info('')
            c.project.removal = removal
            c.project.removal_changed_date = datetime.utcnow()
        if 'delete_icon' in kw:
            M.ProjectFile.query.remove(
                dict(project_id=c.project._id, category='icon'))
            M.AuditLog.log('remove project icon')
            h.log_action(log, 'remove project icon').info('')
            g.post_event('project_updated')
            redirect('overview')
        elif 'delete' in kw:
            allow_project_delete = asbool(
                config.get('allow_project_delete', True))
            if allow_project_delete or not c.project.is_root:
                M.AuditLog.log('delete project')
                h.log_action(log, 'delete project').info('')
                plugin.ProjectRegistrationProvider.get().delete_project(
                    c.project, c.user)
            redirect('overview')
        elif 'undelete' in kw:
            h.log_action(log, 'undelete project').info('')
            M.AuditLog.log('undelete project')
            plugin.ProjectRegistrationProvider.get().undelete_project(
                c.project, c.user)
            redirect('overview')
        if name != c.project.name:
            h.log_action(log, 'change project name').info('')
            M.AuditLog.log('change project name to %s', name)
            c.project.name = name
        if short_description != c.project.short_description:
            h.log_action(log, 'change project short description').info('')
            M.AuditLog.log('change short description to %s', short_description)
            c.project.short_description = short_description
        if summary != c.project.summary:
            h.log_action(log, 'change project summary').info('')
            M.AuditLog.log('change summary to %s', summary)
            c.project.summary = summary
        category = category and ObjectId(category) or None
        if category != c.project.category_id:
            h.log_action(log, 'change project category').info('')
            M.AuditLog.log('change category to %s', category)
            c.project.category_id = category
        if external_homepage != c.project.external_homepage:
            h.log_action(log, 'change external home page').info('')
            M.AuditLog.log('change external home page to %s',
                           external_homepage)
            c.project.external_homepage = external_homepage
        if support_page != c.project.support_page:
            h.log_action(log, 'change project support page').info('')
            M.AuditLog.log('change project support page to %s', support_page)
            c.project.support_page = support_page
        if support_page_url != c.project.support_page_url:
            h.log_action(log, 'change project support page url').info('')
            M.AuditLog.log('change project support page url to %s',
                           support_page_url)
            c.project.support_page_url = support_page_url
        if moved_to_url != c.project.moved_to_url:
            h.log_action(log, 'change project moved to url').info('')
            M.AuditLog.log('change project moved to url to %s', moved_to_url)
            c.project.moved_to_url = moved_to_url
        if export_controlled != c.project.export_controlled:
            h.log_action(log,
                         'change project export controlled status').info('')
            M.AuditLog.log('change project export controlled status to %s',
                           export_controlled)
            c.project.export_controlled = not not export_controlled
            if not export_controlled:
                export_control_type = None
        if export_control_type != c.project.export_control_type:
            h.log_action(log, 'change project export control type').info('')
            M.AuditLog.log('change project export control type to %s',
                           export_control_type)
            c.project.export_control_type = export_control_type
        if tracking_id != c.project.tracking_id:
            h.log_action(log, 'change project tracking ID').info('')
            M.AuditLog.log('change project tracking ID to %s', tracking_id)
            c.project.tracking_id = tracking_id

        if icon is not None and icon != '':
            if c.project.icon:
                M.ProjectFile.remove(
                    dict(project_id=c.project._id, category='icon'))
            M.AuditLog.log('update project icon')
            M.ProjectFile.save_image(icon.filename,
                                     icon.file,
                                     content_type=icon.type,
                                     square=True,
                                     thumbnail_size=(48, 48),
                                     thumbnail_meta=dict(
                                         project_id=c.project._id,
                                         category='icon'))
        g.post_event('project_updated')
        redirect('overview')
Пример #32
0
 def rate_limit(self):
     if WM.Page.is_limit_exceeded(c.app.config):
         msg = 'Page creation rate limit exceeded. '
         log.warn(msg + c.app.config.url())
         flash(msg + 'Please try again later.', 'error')
         redirect('..')
Пример #33
0
 def subscribe(self, subscribe=None, unsubscribe=None):
     if subscribe:
         M.Mailbox.subscribe(type='direct')
     elif unsubscribe:
         M.Mailbox.unsubscribe()
     redirect(request.referer)
Пример #34
0
 def new_page(self, title):
     redirect(h.really_unicode(title).encode('utf-8') + '/')
Пример #35
0
 def index(self, **kw):
     redirect(h.really_unicode(c.app.root_page_name).encode('utf-8') + '/')
Пример #36
0
 def get_all(self, workspace, **kw):
     tg.redirect('/precondition', params=dict(workspace=workspace))
    def deleteinvitation(self, **kw):
        print kw
        self.model.Invitation.deleteById(kw['idinvitation'])

        redirect('/managepoll/invitation/indextest')
Пример #38
0
class ProjectAdminController(BaseController):
    def _check_security(self):
        require_access(c.project, 'admin')

    def __init__(self):
        self.permissions = PermissionsController()
        self.groups = GroupsController()
        self.audit = AuditController()

    @with_trailing_slash
    @expose('jinja:allura.ext.admin:templates/project_admin.html')
    def index(self, **kw):
        return dict()

    @without_trailing_slash
    @expose('jinja:allura.ext.admin:templates/project_invitations.html')
    def invitations(self):
        return dict()

    @without_trailing_slash
    @expose('jinja:allura.ext.admin:templates/project_overview.html')
    def overview(self, **kw):
        c.markdown_editor = W.markdown_editor
        c.metadata_admin = W.metadata_admin
        c.explain_export_modal = W.explain_export_modal
        show_export_control = asbool(config.get('show_export_control', False))
        allow_project_delete = asbool(config.get('allow_project_delete', True))
        explain_export_text = '''The purpose of this section is to determine whether your project is subject to the provisions of the
        US Export Administration Regulations. You should consult section 734.4 and Supplement 2 to Part 734 for information on such items
        and the calculation of U.S. controlled content.
        <a href="http://www.bis.doc.gov/encryption/default.htm" target="_blank">http://www.bis.doc.gov/encryption/default.htm</a>'''
        if 'us_export_contact' in config:
            explain_export_text += 'If you have additional questions, please contact <a href="mailto:{contact}">{contact}</a>.'.format(
                contact=config['us_export_contact'])
        return dict(show_export_control=show_export_control,
                    allow_project_delete=allow_project_delete,
                    explain_export_text=explain_export_text)

    @without_trailing_slash
    @expose('jinja:allura.ext.admin:templates/project_screenshots.html')
    def screenshots(self, **kw):
        c.screenshot_admin = W.screenshot_admin
        c.screenshot_list = W.screenshot_list
        return dict()

    @without_trailing_slash
    @expose('jinja:allura.ext.admin:templates/project_trove.html')
    def trove(self):
        c.label_edit = W.label_edit
        base_troves = M.TroveCategory.query.find(
            dict(trove_parent_id=0)).sort('fullname').all()
        topic_trove = M.TroveCategory.query.get(trove_parent_id=0,
                                                shortname='topic')
        license_trove = M.TroveCategory.query.get(trove_parent_id=0,
                                                  shortname='license')
        return dict(base_troves=base_troves,
                    license_trove=license_trove,
                    topic_trove=topic_trove)

    @without_trailing_slash
    @expose('jinja:allura.ext.admin:templates/project_tools.html')
    def tools(self, **kw):
        c.markdown_editor = W.markdown_editor
        c.label_edit = W.label_edit
        c.mount_delete = W.mount_delete
        c.admin_modal = W.admin_modal
        c.install_modal = W.install_modal
        mounts = c.project.ordered_mounts()
        return dict(
            mounts=mounts,
            installable_tools=AdminApp.installable_tools_for(c.project),
            roles=M.ProjectRole.query.find(
                dict(project_id=c.project.root_project._id)).sort('_id').all(),
            categories=M.ProjectCategory.query.find(
                dict(parent_id=None)).sort('label').all())

    @expose()
    @require_post()
    def update_labels(self, labels=None, labels_old=None, **kw):
        require_access(c.project, 'admin')
        c.project.labels = labels.split(',')
        M.AuditLog.log('updated labels')
        redirect('trove')

    @without_trailing_slash
    @expose()
    def clone(self,
              repo_type=None,
              source_url=None,
              mount_point=None,
              mount_label=None,
              **kw):
        require_access(c.project, 'admin')
        if repo_type is None:
            return ('<form method="get">'
                    '<input name="repo_type" value="Git">'
                    '<input name="source_url">'
                    '<input type="submit">'
                    '</form>')
        for ep in pkg_resources.iter_entry_points('allura', repo_type):
            break
        if ep is None or source_url is None:
            raise exc.HTTPNotFound
        h.log_action(log,
                     'install tool').info('clone repo from %s',
                                          source_url,
                                          meta=dict(tool_type=repo_type,
                                                    mount_point=mount_point,
                                                    mount_label=mount_label))
        c.project.install_app(repo_type,
                              mount_point=mount_point,
                              mount_label=mount_label,
                              init_from_url=source_url)
        M.AuditLog.log('Create repo as clone')
        redirect('tools')

    @without_trailing_slash
    @expose('jinja:allura.ext.admin:templates/project_permissions.html')
    def groups(self, **kw):
        return dict()

    @expose()
    def _lookup(self, name, *remainder):
        app = c.project.app_instance(name)
        if app is None:
            raise exc.HTTPNotFound, name
        return app.admin, remainder

    @expose()
    @require_post()
    @validate(W.metadata_admin, error_handler=overview)
    def update(self,
               name=None,
               short_description=None,
               summary='',
               icon=None,
               category=None,
               external_homepage='',
               support_page='',
               support_page_url='',
               removal='',
               moved_to_url='',
               export_controlled=False,
               export_control_type=None,
               tracking_id='',
               **kw):
        require_access(c.project, 'update')

        if removal != c.project.removal:
            M.AuditLog.log('change project removal status to %s', removal)
            h.log_action(log, 'change project removal status').info('')
            c.project.removal = removal
            c.project.removal_changed_date = datetime.utcnow()
        if 'delete_icon' in kw:
            M.ProjectFile.query.remove(
                dict(project_id=c.project._id, category='icon'))
            M.AuditLog.log('remove project icon')
            h.log_action(log, 'remove project icon').info('')
            g.post_event('project_updated')
            redirect('overview')
        elif 'delete' in kw:
            allow_project_delete = asbool(
                config.get('allow_project_delete', True))
            if allow_project_delete or not c.project.is_root:
                M.AuditLog.log('delete project')
                h.log_action(log, 'delete project').info('')
                plugin.ProjectRegistrationProvider.get().delete_project(
                    c.project, c.user)
            redirect('overview')
        elif 'undelete' in kw:
            h.log_action(log, 'undelete project').info('')
            M.AuditLog.log('undelete project')
            plugin.ProjectRegistrationProvider.get().undelete_project(
                c.project, c.user)
            redirect('overview')
        if name != c.project.name:
            h.log_action(log, 'change project name').info('')
            M.AuditLog.log('change project name to %s', name)
            c.project.name = name
        if short_description != c.project.short_description:
            h.log_action(log, 'change project short description').info('')
            M.AuditLog.log('change short description to %s', short_description)
            c.project.short_description = short_description
        if summary != c.project.summary:
            h.log_action(log, 'change project summary').info('')
            M.AuditLog.log('change summary to %s', summary)
            c.project.summary = summary
        category = category and ObjectId(category) or None
        if category != c.project.category_id:
            h.log_action(log, 'change project category').info('')
            M.AuditLog.log('change category to %s', category)
            c.project.category_id = category
        if external_homepage != c.project.external_homepage:
            h.log_action(log, 'change external home page').info('')
            M.AuditLog.log('change external home page to %s',
                           external_homepage)
            c.project.external_homepage = external_homepage
        if support_page != c.project.support_page:
            h.log_action(log, 'change project support page').info('')
            M.AuditLog.log('change project support page to %s', support_page)
            c.project.support_page = support_page
        if support_page_url != c.project.support_page_url:
            h.log_action(log, 'change project support page url').info('')
            M.AuditLog.log('change project support page url to %s',
                           support_page_url)
            c.project.support_page_url = support_page_url
        if moved_to_url != c.project.moved_to_url:
            h.log_action(log, 'change project moved to url').info('')
            M.AuditLog.log('change project moved to url to %s', moved_to_url)
            c.project.moved_to_url = moved_to_url
        if export_controlled != c.project.export_controlled:
            h.log_action(log,
                         'change project export controlled status').info('')
            M.AuditLog.log('change project export controlled status to %s',
                           export_controlled)
            c.project.export_controlled = not not export_controlled
            if not export_controlled:
                export_control_type = None
        if export_control_type != c.project.export_control_type:
            h.log_action(log, 'change project export control type').info('')
            M.AuditLog.log('change project export control type to %s',
                           export_control_type)
            c.project.export_control_type = export_control_type
        if tracking_id != c.project.tracking_id:
            h.log_action(log, 'change project tracking ID').info('')
            M.AuditLog.log('change project tracking ID to %s', tracking_id)
            c.project.tracking_id = tracking_id

        if icon is not None and icon != '':
            if c.project.icon:
                M.ProjectFile.remove(
                    dict(project_id=c.project._id, category='icon'))
            M.AuditLog.log('update project icon')
            M.ProjectFile.save_image(icon.filename,
                                     icon.file,
                                     content_type=icon.type,
                                     square=True,
                                     thumbnail_size=(48, 48),
                                     thumbnail_meta=dict(
                                         project_id=c.project._id,
                                         category='icon'))
        g.post_event('project_updated')
        redirect('overview')

    def _add_trove(self, type, new_trove):
        current_troves = getattr(c.project, 'trove_%s' % type)
        trove_obj = M.TroveCategory.query.get(trove_cat_id=int(new_trove))
        error_msg = None
        if type in ['license', 'audience', 'developmentstatus', 'language'
                    ] and len(current_troves) >= 6:
            error_msg = 'You may not have more than 6 of this category.'
        elif type in ['topic'] and len(current_troves) >= 3:
            error_msg = 'You may not have more than 3 of this category.'
        elif trove_obj is not None:
            if trove_obj._id not in current_troves:
                current_troves.append(trove_obj._id)
                g.post_event('project_updated')
            else:
                error_msg = 'This category has already been assigned to the project.'
        return (trove_obj, error_msg)

    @expose('json:')
    @require_post()
    def add_trove_js(self, type, new_trove, **kw):
        require_access(c.project, 'update')
        trove_obj, error_msg = self._add_trove(type, new_trove)
        return dict(trove_full_path=trove_obj.fullpath,
                    trove_cat_id=trove_obj.trove_cat_id,
                    error_msg=error_msg)
        redirect('trove')

    @expose()
    @require_post()
    def add_trove(self, type, new_trove, **kw):
        require_access(c.project, 'update')
        trove_obj, error_msg = self._add_trove(type, new_trove)
        M.AuditLog.log('add trove %s: %s', type, trove_obj.fullpath)
        if error_msg:
            flash(error_msg, 'error')
        redirect('trove')

    @expose()
    @require_post()
    def delete_trove(self, type, trove, **kw):
        require_access(c.project, 'update')
        trove_obj = M.TroveCategory.query.get(trove_cat_id=int(trove))
        current_troves = getattr(c.project, 'trove_%s' % type)
        if trove_obj is not None and trove_obj._id in current_troves:
            M.AuditLog.log('remove trove %s: %s', type, trove_obj.fullpath)
            current_troves.remove(trove_obj._id)
            g.post_event('project_updated')
        redirect('trove')

    @expose()
    @require_post()
    @validate(W.screenshot_admin)
    def add_screenshot(self, screenshot=None, caption=None, **kw):
        require_access(c.project, 'update')
        if len(c.project.get_screenshots()) >= 6:
            flash('You may not have more than 6 screenshots per project.',
                  'error')
        elif screenshot is not None and screenshot != '':
            M.AuditLog.log('add screenshot')
            M.ProjectFile.save_image(
                screenshot.filename,
                screenshot.file,
                content_type=screenshot.type,
                save_original=True,
                original_meta=dict(project_id=c.project._id,
                                   category='screenshot',
                                   caption=caption),
                square=True,
                thumbnail_size=(150, 150),
                thumbnail_meta=dict(project_id=c.project._id,
                                    category='screenshot_thumb'))
            g.post_event('project_updated')
        redirect('screenshots')

    @expose()
    @require_post()
    def delete_screenshot(self, id=None, **kw):
        require_access(c.project, 'update')
        if id is not None and id != '':
            M.AuditLog.log('remove screenshot')
            M.ProjectFile.query.remove(
                dict(project_id=c.project._id, _id=ObjectId(id)))
            g.post_event('project_updated')
        redirect('screenshots')

    @expose()
    @require_post()
    def edit_screenshot(self, id=None, caption=None, **kw):
        require_access(c.project, 'update')
        if id is not None and id != '':
            M.ProjectFile.query.get(project_id=c.project._id,
                                    _id=ObjectId(id)).caption = caption
            g.post_event('project_updated')
        redirect('screenshots')

    @expose()
    @require_post()
    def join_neighborhood(self, nid):
        require_access(c.project, 'admin')
        if not nid:
            n = M.Neighborhood.query.get(name='Projects')
            c.project.neighborhood_id = n._id
            flash('Joined %s' % n.name)
            redirect(c.project.url() + 'admin/')
        nid = ObjectId(str(nid))
        if nid not in c.project.neighborhood_invitations:
            flash('No invitation to that neighborhood', 'error')
            redirect('.')
        c.project.neighborhood_id = nid
        n = M.Neighborhood.query.get(_id=nid)
        flash('Joined %s' % n.name)
        redirect('invitations')

    @h.vardec
    @expose()
    @require_post()
    def update_mount_order(self, subs=None, tools=None, **kw):
        if subs:
            for sp in subs:
                p = M.Project.query.get(
                    shortname=sp['shortname'],
                    neighborhood_id=c.project.neighborhood_id)
                p.ordinal = int(sp['ordinal'])
        if tools:
            for p in tools:
                c.project.app_config(p['mount_point']).options.ordinal = int(
                    p['ordinal'])
        redirect('tools')

    @h.vardec
    @expose()
    @require_post()
    def update_mounts(self, subproject=None, tool=None, new=None, **kw):
        if subproject is None: subproject = []
        if tool is None: tool = []
        for sp in subproject:
            p = M.Project.query.get(shortname=sp['shortname'],
                                    neighborhood_id=c.project.neighborhood_id)
            if sp.get('delete'):
                require_access(c.project, 'admin')
                M.AuditLog.log('delete subproject %s', sp['shortname'])
                h.log_action(log, 'delete subproject').info(
                    'delete subproject %s',
                    sp['shortname'],
                    meta=dict(name=sp['shortname']))
                p.removal = 'deleted'
                plugin.ProjectRegistrationProvider.get().delete_project(
                    p, c.user)
            elif not new:
                M.AuditLog.log('update subproject %s', sp['shortname'])
                p.name = sp['name']
                p.ordinal = int(sp['ordinal'])
        for p in tool:
            if p.get('delete'):
                require_access(c.project, 'admin')
                M.AuditLog.log('uninstall tool %s', p['mount_point'])
                h.log_action(log, 'uninstall tool').info(
                    'uninstall tool %s',
                    p['mount_point'],
                    meta=dict(mount_point=p['mount_point']))
                c.project.uninstall_app(p['mount_point'])
            elif not new:
                M.AuditLog.log('update tool %s', p['mount_point'])
                options = c.project.app_config(p['mount_point']).options
                options.mount_label = p['mount_label']
                options.ordinal = int(p['ordinal'])
        try:
            if new and new.get('install'):
                ep_name = new.get('ep_name', None)
                if not ep_name:
                    require_access(c.project, 'create')
                    mount_point = new['mount_point'].lower() or h.nonce()
                    M.AuditLog.log('create subproject %s', mount_point)
                    h.log_action(log, 'create subproject').info(
                        'create subproject %s',
                        mount_point,
                        meta=dict(mount_point=mount_point,
                                  name=new['mount_label']))
                    sp = c.project.new_subproject(mount_point)
                    sp.name = new['mount_label']
                    sp.ordinal = int(new['ordinal'])
                else:
                    require_access(c.project, 'admin')
                    mount_point = new['mount_point'].lower() or ep_name.lower()
                    M.AuditLog.log('install tool %s', mount_point)
                    h.log_action(log, 'install tool').info(
                        'install tool %s',
                        mount_point,
                        meta=dict(tool_type=ep_name,
                                  mount_point=mount_point,
                                  mount_label=new['mount_label']))
                    c.project.install_app(ep_name,
                                          mount_point,
                                          mount_label=new['mount_label'],
                                          ordinal=new['ordinal'])
        except forge_exc.ForgeError, exc:
            flash('%s: %s' % (exc.__class__.__name__, exc.args[0]), 'error')
        g.post_event('project_updated')
        redirect('tools')
Пример #39
0
 def index(self, offset=0, branch=None, **kw):
     if branch is None:
         branch = c.app.default_branch_name
     redirect(c.app.repo.url_for_commit(branch, url_type='ref'))
Пример #40
0
 def update_labels(self, labels=None, labels_old=None, **kw):
     require_access(c.project, 'admin')
     c.project.labels = labels.split(',')
     M.AuditLog.log('updated labels')
     redirect('trove')
Пример #41
0
 def merge(self):
     if not self.req.merge_allowed(c.user) or not self.req.can_merge():
         raise exc.HTTPNotFound
     self.req.merge()
     redirect(self.req.url())
Пример #42
0
def permanent_redirect(url):
    try:
        tg.redirect(url)
    except exc.HTTPFound, err:
        raise exc.HTTPMovedPermanently(location=err.location)
Пример #43
0
 def redirect_list(self):
     tg.redirect(["/sub2", "list"])
Пример #44
0
 def log(self, **kw):
     ci = c.app.repo.commit(self._branch)
     redirect(ci.url() + 'log/')
Пример #45
0
 def redirect_me(self, target, **kw):
     tg.redirect(target, params=kw)
Пример #46
0
 def index(self):
     tg.redirect('list')
Пример #47
0
 def bigflash_redirect(self):
     tg.flash('x' * 5000)
     tg.redirect('/flash_after_redirect')
Пример #48
0
 def redirect_sub(self):
     tg.redirect('index')
Пример #49
0
 def redirect_cookie(self, name):
     tg.response.set_cookie('name', name)
     tg.redirect('/hello_cookie')
Пример #50
0
 def flash_unicode(self):
     tg.flash(u_("Привет, мир!"))
     tg.redirect("/flash_after_redirect")
Пример #51
0
    def update(self, name=None, css=None, homepage=None, project_template=None, icon=None, **kw):
        nbhd = self.neighborhood
        c.project = nbhd.neighborhood_project
        h.log_if_changed(nbhd, 'name', name,
                         'change neighborhood name to %s' % name)
        nbhd_redirect = kw.pop('redirect', '')
        h.log_if_changed(nbhd, 'redirect', nbhd_redirect,
                         'change neighborhood redirect to %s' % nbhd_redirect)
        h.log_if_changed(nbhd, 'homepage', homepage,
                         'change neighborhood homepage to %s' % homepage)
        h.log_if_changed(nbhd, 'css', css,
                         'change neighborhood css to %s' % css)
        h.log_if_changed(nbhd, 'project_template', project_template,
                         'change neighborhood project template to %s'
                         % project_template)
        allow_browse = kw.get('allow_browse', False)
        h.log_if_changed(nbhd, 'allow_browse', allow_browse,
                         'change neighborhood allow browse to %s'
                         % allow_browse)
        show_title = kw.get('show_title', False)
        h.log_if_changed(nbhd, 'show_title', show_title,
                         'change neighborhood show title to %s' % show_title)
        use_wiki_page_as_root = kw.get('use_wiki_page_as_root', False)
        h.log_if_changed(nbhd, 'use_wiki_page_as_root', use_wiki_page_as_root,
                         'change use wiki page as root to %s' % use_wiki_page_as_root)
        project_list_url = kw.get('project_list_url', '')
        h.log_if_changed(nbhd, 'project_list_url', project_list_url,
                         'change neighborhood project list url to %s'
                         % project_list_url)
        tracking_id = kw.get('tracking_id', '')
        h.log_if_changed(nbhd, 'tracking_id', tracking_id,
                         'update neighborhood tracking_id')
        prohibited_tools = kw.get('prohibited_tools', '')

        result = True
        if prohibited_tools.strip() != '':
            for prohibited_tool in prohibited_tools.split(','):
                if prohibited_tool.strip() not in g.entry_points['tool']:
                    flash('Prohibited tools "%s" is invalid' %
                          prohibited_tool.strip(), 'error')
                    result = False

        if result:
            h.log_if_changed(nbhd, 'prohibited_tools', prohibited_tools,
                             'update neighborhood prohibited tools')

        anchored_tools = kw.get('anchored_tools', '')
        validate_tools = dict()
        result = True
        if anchored_tools.strip() != '':
            try:
                validate_tools = dict(
                    (tool.split(':')[0].lower(), tool.split(':')[1])
                    for tool in anchored_tools.replace(' ', '').split(','))
            except Exception:
                flash('Anchored tools "%s" is invalid' %
                      anchored_tools, 'error')
                result = False

        for tool in validate_tools.keys():
            if tool not in g.entry_points['tool']:
                flash('Anchored tools "%s" is invalid' %
                      anchored_tools, 'error')
                result = False
        if result:
            h.log_if_changed(nbhd, 'anchored_tools', anchored_tools,
                             'update neighborhood anchored tools')

        if icon is not None and icon != '':
            if self.neighborhood.icon:
                self.neighborhood.icon.delete()
                M.ProjectFile.query.remove(dict(project_id=c.project._id, category=re.compile(r'^icon')))
            M.AuditLog.log('update neighborhood icon')
            c.project.save_icon(icon.filename, icon.file, content_type=icon.type)
        redirect('overview')
Пример #52
0
 def flash_redirect(self):
     tg.flash("Wow, <br/>flash!")
     tg.redirect("/flash_after_redirect")
Пример #53
0
 def index(self, offset=0, branch=None, **kw):
     if branch is None:
         branch=c.app.default_branch_name
     redirect(url(quote('%s%s/' % (
                     branch, c.app.END_OF_REF_ESCAPE))))
Пример #54
0
 def index(self, **kw):
     require_access(self.neighborhood, 'admin')
     if self.grant is not None:
         return dict(grant=self.grant)
     else:
         redirect('not_found')
Пример #55
0
 def index(self, *args, **kw):
     redirect('/mono')
Пример #56
0
 def revoke(self):
     require_access(self.neighborhood, 'admin')
     self.grant.delete()
     with h.push_context(self.project._id):
         g.post_event('project_updated')
     redirect(request.referer)
Пример #57
0
 def new(self, **kw):
     require_access(self.thread, 'post')
     kw = self.W.edit_post.to_python(kw, None)
     p = self.thread.add_post(**kw)
     redirect(p.slug + '/')
Пример #58
0
 def save(self, status=None):
     security.require(
         security.has_access(self.req, 'write'), 'Write access required')
     self.req.status = status
     redirect('.')
Пример #59
0
 def reply(self, **kw):
     require_access(self.thread, 'post')
     kw = self.W.edit_post.to_python(kw, None)
     post = self.thread.post(parent_id=self.post._id, **kw)
     self.thread.num_replies += 1
     redirect(post.slug.split('/')[-1] + '/')
Пример #60
0
 def index(self, **kw):
     redirect('home')