Exemplo n.º 1
0
    def files(self, group):
        file_id = request.GET.get('serve_file')
        file = File.get(file_id)
        c.serve_file = file

        c.group_menu_current_item = 'files'
        c.show_info = True

        return render('group/files.mako')
Exemplo n.º 2
0
    def _group_action(self, id, file_id):
        group = Group.get(id)
        if group is None:
            abort(404)

        file = File.get(file_id)
        if file not in group.files:
            abort(404)

        c.security_context = file
        c.object_location = group.location
        c.group = group
        c.breadcrumbs = [{'title': group.title, 'link': group.url()}]
        return method(self, group, file)
Exemplo n.º 3
0
    def undelete(self, id):
        if hasattr(self, 'form_result'):
            parent = self.form_result['parent_id']
            file = File.get(id)
            if file is None:
                abort(404)

            if parent is None:
                if file.parent is None:
                    abort(400)
            else:
                file.parent = parent

            file.deleted_by = None
            meta.Session.commit()
            redirect(url(controller='admin', action='deleted_files'))
        else:
            abort(400) #bad request
Exemplo n.º 4
0
    def get(self, id):
        if isinstance(id, basestring):
            id = re.search(r"\d*", id).group()

        if not id:
            abort(404)

        file = File.get(id)
        if file is None:
            abort(404)
        if file.parent is not None:
            redirect(file.url())
        elif is_root(c.user):
            return self._get(file)
        else:
            c.login_form_url = url(controller='home',
                                   action='login',
                                   came_from=file.url())
            deny(_('You have no right to download this file.'), 403)
Exemplo n.º 5
0
    def _subject_action(self, id, tags, file_id):
        location = LocationTag.get(tags)
        subject = Subject.get(location, id)

        if subject is None:
            abort(404)

        file = File.get(file_id)
        if file is None:
            abort(404)

        if (file not in subject.files
            and not file.can_write()):
            abort(404)

        c.object_location = subject.location
        c.security_context = file
        c.subject = subject
        c.theme = subject.location.get_theme()
        return method(self, subject, file)
Exemplo n.º 6
0
    def _group_action(self, id, message_id, file_id):
        group = Group.get(id)
        if group is None:
            abort(404)

        message = meta.Session.query(GroupMailingListMessage).filter_by(id=message_id).first()
        if message is None:
            abort(404)

        if isinstance(file_id, basestring):
            file_id = re.search(r"\d*", file_id).group()
        file = File.get(file_id)
        if file is None:
            #not in group.files: ??? are mailing list files added as the group's files?
            abort(404)

        c.security_context = group
        c.object_location = group.location
        c.group = group
        c.group_menu_items = group_menu_items()
        c.breadcrumbs = [{'title': group.title, 'link': group.url()}]
        c.theme = group.location.get_theme()
        return method(self, group, message, file)
Exemplo n.º 7
0
 def files(self, subject):
     c.current_tab = 'files'
     file_id = request.GET.get('serve_file')
     file = File.get(file_id)
     c.serve_file = file
     return render('subject/home_files.mako')
Exemplo n.º 8
0
 def delete(self, id):
     file = File.get(id)
     if file is None:
         abort(404)
     return self._delete(file)