コード例 #1
0
ファイル: comp.py プロジェクト: blugand/kansha
    def update_card_position(self, data):
        security.check_permissions('edit', self)
        data = json.loads(data)

        cols = {}
        for col in self.columns:
            cols[col().id] = col()

        orig = cols[data['orig']]

        if data['orig'] != data['dest']:  # Move from one column to another
            dest = cols[data['dest']]
            card = orig.remove_card(data['card'])
            dest.insert_card(card, data['index'])
            values = {'from': orig.title().text,
                      'to': dest.title().text,
                      'card': card().data.title}
            notifications.add_history(self.data, card().data,
                                      security.get_user().data,
                                      u'card_move', values)
            # reindex it in case it has been moved to the archive column
            scard = fts_schema.Card.from_model(card().data)
            self.search_engine.update_document(scard)
            self.search_engine.commit()
        else:  # Reorder only
            orig.move_card(data['card'], data['index'])
        session.flush()
コード例 #2
0
def render_Board(self, h, comp, *args):
    """Main board renderer"""
    security.check_permissions('view', self)
    h.head.css_url('css/themes/board.css')
    h.head.css_url('css/themes/%s/board.css' % self.theme)

    h.head.javascript_url('js/jquery-searchinput/jquery.searchinput.js')
    h.head.javascript_url('js/debounce.js')
    h.head.css_url('js/jquery-searchinput/styles/jquery.searchinput.min.css')
    h.head.javascript('searchinput', '''jQuery(document).ready(function ($) { $('#search').searchInput(); });''')
    title = '%s - %s' % (self.get_title(), self.app_title)
    h.head << h.head.title(title)
    if security.has_permissions('edit', self):
        h << comp.render(h, "menu")

    h << self.modal

    with h.div(class_='board'):
        if self.background_image_url:
            h << {'class': 'board ' + self.background_image_position,
                  'style': 'background-image:url(%s)' % self.background_image_url}
        with h.div(class_='header'):
            with h.div(class_='board-title', style='color: %s' % self.title_color):
                h << self.title.render(h.AsyncRenderer(), 0 if security.has_permissions('edit', self) else 'readonly')
            h << comp.render(h, 'switch')
        with h.div(class_='bbody'):
            h << comp.render(h.AsyncRenderer(), self.model)
    return h.root
コード例 #3
0
ファイル: view.py プロジェクト: amatthi/mazik
def render_Board(self, h, comp, *args):
    """Main board renderer"""
    security.check_permissions('view', self)
    self.refresh_on_version_mismatch()
    self.card_filter.reload_search()
    h.head.css_url('css/themes/board.css?v=2c')
    h.head.css_url('css/themes/%s/board.css?v=2c' % self.theme)

    title = '%s - %s' % (self.get_title(), self.app_title)
    h.head << h.head.title(title)
    if security.has_permissions('edit', self):
        h << comp.render(h.AsyncRenderer(), "menu")

    with h.div(class_='board'):
        if self.background_image_url:
            h << {
                'class': 'board ' + self.background_image_position,
                'style': 'background-image:url(%s)' % self.background_image_url
            }
        with h.div(class_='header'):
            with h.div(class_='board-title',
                       style='color: %s' % self.title_color):
                h << self.title.render(
                    h.AsyncRenderer(), 0 if security.has_permissions(
                        'edit', self) else 'readonly')
            h << comp.render(h, 'switch')
        with h.div(class_='bbody'):
            h << comp.render(h.AsyncRenderer(), self.model)
    return h.root
コード例 #4
0
ファイル: comp.py プロジェクト: blugand/kansha
    def move_cards(self, v):
        """Function called after drag and drop of a card or column

        In:
            - ``v`` -- a structure containing the lists/cards position
                       (ex . [ ["list_1", ["card_1", "card_2"]],
                             ["list_2", ["card_3", "card_4"]] ])
        """
        security.check_permissions('edit', self)
        ids = json.loads(v)
        cards = {}
        cols = {}

        for col in self.columns:
            cards.update(dict([(card().id, card) for card in col().cards
                               if not isinstance(card(), popin.Empty)]))
            cols[col().id] = col

        # move columns
        self.columns = []
        for (col_index, (col_id, card_ids)) in enumerate(ids):
            comp_col = cols[col_id]
            self.columns.append(comp_col)
            comp_col().change_index(col_index)
            comp_col().move_cards([cards[id_] for id_ in card_ids])

        session.flush()
コード例 #5
0
    def edit(self, comp):
        content = comp.call(PageEditor(self))

        if content is not None:
            security.check_permissions('wiki.editor', self)
            page = PageData.get_by(pagename=self.title)
            page.data = content
コード例 #6
0
ファイル: comp.py プロジェクト: blugand/kansha
    def add(self, v):
        """Add a new comment to the card

        In:
            - ``v`` -- the comment content
        """
        security.check_permissions('comment', self.parent)
        if v is None:
            return
        v = v.strip()
        if v:
            v = validator.clean_text(v)
            user = security.get_user()
            comment = DataComment(comment=v.strip(),
                                  card_id=self.parent.data.id,
                                  author=user.data,
                                  creation_date=datetime.datetime.utcnow())
            session.add(comment)
            session.flush()
            data = {'comment': v.strip(), 'card': self.parent.title().text}
            notifications.add_history(self.parent.column.board.data,
                                      self.parent.data,
                                      security.get_user().data,
                                      u'card_add_comment', data)
            self.comments.insert(0, self._create_comment_component(comment))
コード例 #7
0
ファイル: wiki15.py プロジェクト: nagareproject/examples
    def edit(self, comp):
        content = comp.call(PageEditor(self))

        if content is not None:
            security.check_permissions('wiki.editor', self)
            page = PageData.get_by(pagename=self.title)
            page.data = content
コード例 #8
0
ファイル: view.py プロジェクト: droodle/kansha
def render_Board(self, h, comp, *args):
    """Main board renderer"""

    h.head.javascript_url('js/jquery-searchinput/jquery.searchinput.js')
    h.head.javascript_url('js/debounce.js')
    h.head.css_url('js/jquery-searchinput/styles/jquery.searchinput.min.css')
    h.head.javascript('searchinput', "jQuery(document).ready(function ($) {$('#search').searchInput();});")
    h << self.title.render(h, 'tabname')
    security.check_permissions('view', self)
    if security.has_permissions('edit', self):
        h << comp.render(h, "menu")

    # TODO: Remove this popin
    h << self.popin.render(h.AsyncRenderer())

    background_image_url = self.background_image_url
    background_image_position = self.background_image_position

    if background_image_url:
        styles = {'repeat': 'background:url(%s) repeat' % background_image_url,
                  'cover': 'background:url(%s) no-repeat; background-size:cover' % background_image_url}
        style = styles[background_image_position]
    else:
        style = ''

    with h.div(class_='board', style=style):
        with h.div(class_='header'):
            h << self.title.render(h.AsyncRenderer())
            h << comp.render(h, 'switch')
        with h.div(class_='bbody'):
            h << comp.render(h.AsyncRenderer(), self.model)
    return h.root
コード例 #9
0
ファイル: comp.py プロジェクト: gpaugam/kansha
    def move_cards(self, v):
        """Function called after drag and drop of a card or column

        In:
            - ``v`` -- a structure containing the lists/cards position
                       (ex . [ ["list_1", ["card_1", "card_2"]],
                             ["list_2", ["card_3", "card_4"]] ])
        """
        security.check_permissions('edit', self)
        ids = json.loads(v)
        cards = {}
        cols = {}

        for col in self.columns:
            cards.update(dict([(card().id, card) for card in col().cards
                               if not isinstance(card(), popin.Empty)]))
            cols[col().id] = col

        # move columns
        self.columns = []
        for (col_index, (col_id, card_ids)) in enumerate(ids):
            comp_col = cols[col_id]
            self.columns.append(comp_col)
            comp_col().change_index(col_index)
            comp_col().move_cards([cards[id_] for id_ in card_ids])

        session.flush()
コード例 #10
0
ファイル: comp.py プロジェクト: Reigel/kansha
    def add(self, v):
        """Add a new comment to the card

        In:
            - ``v`` -- the comment content
        """
        security.check_permissions("comment", self.parent)
        if v is None:
            return
        v = v.strip()
        if v:
            v = validator.clean_text(v)
            user = security.get_user()
            comment = DataComment(
                comment=v.strip(),
                card_id=self.parent.data.id,
                author=user.data,
                creation_date=datetime.datetime.utcnow(),
            )
            session.add(comment)
            session.flush()
            data = {"comment": v.strip(), "card": self.parent.title().text}
            notifications.add_history(
                self.parent.column.board.data, self.parent.data, security.get_user().data, u"card_add_comment", data
            )
            self.comments.insert(0, self._create_comment_component(comment))
コード例 #11
0
ファイル: comp.py プロジェクト: gpaugam/kansha
    def update_card_position(self, data):
        security.check_permissions('edit', self)
        data = json.loads(data)

        cols = {}
        for col in self.columns:
            cols[col().id] = col()

        orig = cols[data['orig']]

        if data['orig'] != data['dest']:  # Move from one column to another
            dest = cols[data['dest']]
            card = orig.remove_card(data['card'])
            dest.insert_card(card, data['index'])
            values = {'from': orig.title().text,
                      'to': dest.title().text,
                      'card': card().data.title}
            notifications.add_history(self.data, card().data,
                                      security.get_user().data,
                                      u'card_move', values)
            # reindex it in case it has been moved to the archive column
            scard = fts_schema.Card.from_model(card().data)
            self.search_engine.update_document(scard)
            self.search_engine.commit()
        else:  # Reorder only
            orig.move_card(data['card'], data['index'])
        session.flush()
コード例 #12
0
ファイル: comp.py プロジェクト: ephilippot/kansha
 def unvote(self):
     """Remove a vote to the current card
     """
     security.check_permissions('vote', self.parent)
     if self.has_voted():
         user = security.get_user()
         card_data = self.parent.data
         vote = DataVote.get_vote(user.data, card_data)
         self.votes.remove(vote)
コード例 #13
0
    def edit(self, comp):
        content = comp.call(PageEditor(self))

        if content is not None:
            # Our security policy : a user needs to have the ``wiki.editor`` permission
            # to be able to modify the content of a page
            security.check_permissions('wiki.editor', self)
            page = PageData.get_by(pagename=self.title)
            page.data = content
コード例 #14
0
ファイル: wiki10.py プロジェクト: nagareproject/examples
    def edit(self, comp):
        content = comp.call(PageEditor(self))

        if content is not None:
            # Our security policy : a user needs to have the ``wiki.editor`` permission
            # to be able to modify the content of a page
            security.check_permissions('wiki.editor', self)
            page = PageData.get_by(pagename=self.title)
            page.data = content
コード例 #15
0
ファイル: comp.py プロジェクト: blugand/kansha
 def unvote(self):
     """Remove a vote to the current card
     """
     security.check_permissions('vote', self.parent)
     if self.has_voted():
         user = security.get_user()
         card_data = self.parent.data
         vote = DataVote.get_vote(user.data, card_data)
         self.votes.remove(vote)
コード例 #16
0
ファイル: app.py プロジェクト: nagareproject/ide
    def start_request(self, root, request, response):
        """A new request is received, setup its dedicated environment

        In:
          - ``root`` -- the application root component
          - ``request`` -- the web request object
          - ``response`` -- the web response object
        """
        super(WSGIApp, self).start_request(root, request, response)

        security.check_permissions('connection')
コード例 #17
0
ファイル: comp.py プロジェクト: daamien/kansha
    def toggle(self):
        '''Add a vote to the current card.

        Remove vote if user has already voted
        '''
        security.check_permissions('vote', self.card)
        user = security.get_user()
        if self.has_voted():
            DataVote.get_vote(self.card.data, user.data).delete()
        else:
            DataVote(card=self.card.data, user=user.data)
コード例 #18
0
ファイル: comp.py プロジェクト: daamien/kansha
    def toggle(self):
        '''Add a vote to the current card.

        Remove vote if user has already voted
        '''
        security.check_permissions('vote', self.card)
        user = security.get_user()
        if self.has_voted():
            DataVote.get_vote(self.card.data, user.data).delete()
        else:
            DataVote(card=self.card.data, user=user.data)
コード例 #19
0
ファイル: comp.py プロジェクト: ephilippot/kansha
    def vote(self):
        """Add a vote to the current card.

        Remove vote if user has already voted
        """
        security.check_permissions('vote', self.parent)
        if not self.has_voted():
            user = security.get_user()
            card_data = self.parent.data  # Garbage collector pbm with ORM
            vote = DataVote(user=user.data)
            self.votes.append(vote)
        else:
            self.unvote()
コード例 #20
0
ファイル: comp.py プロジェクト: blugand/kansha
    def vote(self):
        """Add a vote to the current card.

        Remove vote if user has already voted
        """
        security.check_permissions('vote', self.parent)
        if not self.has_voted():
            user = security.get_user()
            card_data = self.parent.data  # Garbage collector pbm with ORM
            vote = DataVote(user=user.data)
            self.votes.append(vote)
        else:
            self.unvote()
コード例 #21
0
ファイル: wiki16.py プロジェクト: jean/examples
    def edit(self, comp):
        content = comp.call(PageEditor(self))

        if content is not None:
            log.info('New content for page [%s]: [%s...]' % (self.title, content[:50]))
            security.check_permissions('wiki.editor', self)
            page = PageData.get_by(pagename=self.title)
            page.data = content

            # If the creator of the page is not already set, set it with the
            # current user
            if page.creator is None:
                page.creator = security.get_user().id
                log.debug('New creator for page [%s]: [%s]' % (page.pagename, page.creator))
コード例 #22
0
ファイル: wiki16.py プロジェクト: nagareproject/examples
    def edit(self, comp):
        content = comp.call(PageEditor(self))

        if content is not None:
            log.info('New content for page [%s]: [%s...]' % (self.title, content[:50]))
            security.check_permissions('wiki.editor', self)
            page = PageData.get_by(pagename=self.title)
            page.data = content

            # If the creator of the page is not already set, set it with the
            # current user
            if page.creator is None:
                page.creator = security.get_user().id
                log.debug('New creator for page [%s]: [%s]' % (page.pagename, page.creator))
コード例 #23
0
ファイル: comp.py プロジェクト: blugand/kansha
    def delete_column(self, id_):
        """Delete a board's column

        In:
            - ``id_`` -- the id of the column to delete
        """

        security.check_permissions('edit', self)
        for comp in self.columns:
            if comp().data.id == id_:
                self.columns.remove(comp)
                comp().delete()
                self.increase_version()
                return popin.Empty()
        raise exceptions.KanshaException('No column with id [%s] found' % id_)
コード例 #24
0
ファイル: comp.py プロジェクト: ephilippot/kansha
    def create_column(self, index, title, nb_cards=None, archive=False):
        """Create a new column in the board

        In:
            - ``index`` -- the position of the column as an integer
            - ``title`` -- the title of the new column
            - ``nb_cards`` -- the number of maximun cards on the colum
        """
        security.check_permissions('edit', self)
        if title == '':
            return False
        col = DataColumn.create_column(self.data, index, title, nb_cards, archive=archive)
        self.columns.insert(index, component.Component(column.Column(col.id, self, self.assets_manager, self.search_engine), 'new'))
        self.increase_version()
        return col.id
コード例 #25
0
ファイル: comp.py プロジェクト: blugand/kansha
 def update_column_position(self, data):
     security.check_permissions('edit', self)
     data = json.loads(data)
     cols = []
     found = None
     for col in self.columns:
         if col().id == data['list']:
             found = col
         else:
             cols.append(col)
     cols.insert(data['index'], found)
     for i, col in enumerate(cols):
         col().change_index(i)
     self.columns = cols
     session.flush()
コード例 #26
0
ファイル: comp.py プロジェクト: gpaugam/kansha
    def delete_column(self, id_):
        """Delete a board's column

        In:
            - ``id_`` -- the id of the column to delete
        """

        security.check_permissions('edit', self)
        for comp in self.columns:
            if comp().data.id == id_:
                self.columns.remove(comp)
                comp().delete()
                self.increase_version()
                return popin.Empty()
        raise exceptions.KanshaException('No column with id [%s] found' % id_)
コード例 #27
0
ファイル: comp.py プロジェクト: gpaugam/kansha
 def update_column_position(self, data):
     security.check_permissions('edit', self)
     data = json.loads(data)
     cols = []
     found = None
     for col in self.columns:
         if col().id == data['list']:
             found = col
         else:
             cols.append(col)
     cols.insert(data['index'], found)
     for i, col in enumerate(cols):
         col().change_index(i)
     self.columns = cols
     session.flush()
コード例 #28
0
ファイル: comp.py プロジェクト: blugand/kansha
    def create_column(self, index, title, nb_cards=None, archive=False):
        """Create a new column in the board

        In:
            - ``index`` -- the position of the column as an integer
            - ``title`` -- the title of the new column
            - ``nb_cards`` -- the number of maximun cards on the colum
        """
        security.check_permissions('edit', self)
        if title == '':
            return False
        col = DataColumn.create_column(self.data, index, title, nb_cards, archive=archive)
        if not archive or (archive and self.archive):
            self.columns.insert(index, component.Component(self._services(column.Column, col.id, self, self.search_engine), 'new'))
        self.increase_version()
        return col.id
コード例 #29
0
ファイル: view.py プロジェクト: blugand/kansha
def render_Board(self, h, comp, *args):
    """Main board renderer"""

    h.head.css_url('css/themes/board.css')
    h.head.css_url('css/themes/%s/board.css' % self.theme)

    h.head.javascript_url('js/jquery-searchinput/jquery.searchinput.js')
    h.head.javascript_url('js/debounce.js')
    h.head.css_url('js/jquery-searchinput/styles/jquery.searchinput.min.css')
    h.head.javascript(
        'searchinput',
        '''jQuery(document).ready(function ($) { $('#search').searchInput(); });'''
    )
    h << self.title.render(h, 'tabname')
    security.check_permissions('view', self)
    if security.has_permissions('edit', self):
        h << comp.render(h, "menu")

    # TODO: Remove this popin
    h << self.popin.render(h.AsyncRenderer())

    background_image_url = self.background_image_url
    background_image_position = self.background_image_position

    if background_image_url:
        styles = {
            'repeat':
            'background:url(%s) repeat' % background_image_url,
            'cover':
            'background:url(%s) no-repeat; background-size:cover' %
            background_image_url
        }
        style = styles[background_image_position]
    else:
        style = ''

    with h.div(class_='board', style=style):
        with h.div(class_='header'):
            h << self.title.render(h.AsyncRenderer())
            h << comp.render(h, 'switch')
        with h.div(class_='bbody'):
            h << comp.render(h.AsyncRenderer(), self.model)
    return h.root
コード例 #30
0
ファイル: comp.py プロジェクト: droodle/kansha
    def update_card_position(self, data):
        security.check_permissions("edit", self)
        data = json.loads(data)

        cols = {}
        for col in self.columns:
            cols[col().id] = col()

        orig = cols[data["orig"]]

        if data["orig"] != data["dest"]:  # Move from one column to another
            dest = cols[data["dest"]]
            card = orig.remove_card(data["card"])
            dest.insert_card(card, data["index"])
            values = {"from": orig.title().text, "to": dest.title().text, "card": card().data.title}
            notifications.add_history(self.data, card().data, security.get_user().data, u"card_move", values)
        else:  # Reorder only
            orig.move_card(data["card"], data["index"])
        session.flush()
コード例 #31
0
ファイル: comp.py プロジェクト: daamien/kansha
    def add(self, v):
        """Add a new comment to the card

        In:
            - ``v`` -- the comment content
        """
        security.check_permissions('comment', self.card)
        if v is None:
            return
        v = v.strip()
        if v:
            v = validator.clean_text(v)
            user = security.get_user()
            comment = DataComment(comment=v, card_id=self.card.db_id,
                                  author=user.data, creation_date=datetime.datetime.utcnow())
            session.add(comment)
            session.flush()
            data = {'comment': v.strip(), 'card': self.card.get_title()}
            self.action_log.add_history(security.get_user(), u'card_add_comment', data)
            self.comments.insert(0, self._create_comment_component(comment))
コード例 #32
0
ファイル: comp.py プロジェクト: ephilippot/kansha
    def update_card_position(self, data):
        security.check_permissions('edit', self)
        data = json.loads(data)

        cols = {}
        for col in self.columns:
            cols[col().id] = col()

        orig = cols[data['orig']]

        if data['orig'] != data['dest']:  # Move from one column to another
            dest = cols[data['dest']]
            card = orig.remove_card(data['card'])
            dest.insert_card(card, data['index'])
            values = {'from': orig.title().text,
                      'to': dest.title().text,
                      'card': card().data.title}
            notifications.add_history(self.data, card().data,
                                      security.get_user().data,
                                      u'card_move', values)
        else:  # Reorder only
            orig.move_card(data['card'], data['index'])
        session.flush()
コード例 #33
0
ファイル: view.py プロジェクト: Net-ng/kansha
def render_Board(self, h, comp, *args):
    """Main board renderer"""
    security.check_permissions('view', self)
    self.refresh_on_version_mismatch()
    self.card_filter.reload_search()
    h.head.css_url('css/themes/board.css?v=2c')
    h.head.css_url('css/themes/%s/board.css?v=2c' % self.theme)

    title = '%s - %s' % (self.get_title(), self.app_title)
    h.head << h.head.title(title)
    if security.has_permissions('edit', self):
        h << comp.render(h.AsyncRenderer(), "menu")

    with h.div(class_='board'):
        if self.background_image_url:
            h << {'class': 'board ' + self.background_image_position,
                  'style': 'background-image:url(%s)' % self.background_image_url}
        with h.div(class_='header'):
            with h.div(class_='board-title', style='color: %s' % self.title_color):
                h << self.title.render(h.AsyncRenderer(), 0 if security.has_permissions('edit', self) else 'readonly')
            h << comp.render(h, 'switch')
        with h.div(class_='bbody'):
            h << comp.render(h.AsyncRenderer(), self.model)
    return h.root