Ejemplo n.º 1
0
class Proposals(ProposalListingTab):
    """Recursively list proposals."""

    grok.name('tabbedview_view-proposals')
    grok.context(IDossierMarker)

    enabled_actions = []
    major_actions = []
    sort_on = 'title'
    show_selects = False

    template = ViewPageTemplateFile("generic_with_filters.pt")

    model = Proposal

    filterlist_name = 'proposal_state_filter'
    filterlist_available = True

    filterlist = FilterList(
        Filter('filter_all', _('label_tabbedview_filter_all')),
        ActiveProposalFilter('filter_active', _('Active'), default=True))

    def get_base_query(self):
        return Proposal.query.by_container(self.context,
                                           get_current_admin_unit())
Ejemplo n.º 2
0
    def filterlist(self):
        filters = [self.all_filter, self.active_filter]

        if api.user.has_permission('opengever.disposition: Add disposition'):
            filters.append(self.expired_filter)

        return FilterList(*filters)
Ejemplo n.º 3
0
    def test_only_one_default_filter_possible(self):
        with self.assertRaises(ValueError) as cm:
            FilterList(Filter('all', 'All', default=True),
                       Filter('active', 'Active', default=True))

        self.assertEquals('Only one filter marked as default possible.',
                          str(cm.exception))
Ejemplo n.º 4
0
    def setUp(self):
        super(TestFilterList, self).setUp()

        self.filter_all = Filter('filter_all', 'All')
        self.filter_active = CatalogQueryFilter(
            'filter_active',
            'Active',
            default=True,
            query_extension={'review_state': ['state-open']})
        self.filter_closed = CatalogQueryFilter(
            'filter_closed',
            'Closed',
            query_extension={'review_state': ['state-closed']})

        self.filter_list = FilterList(self.filter_all, self.filter_active,
                                      self.filter_closed)
class MyTasks(GlobalTaskListingTab):
    """A listing view, which lists all tasks where the given
    user is responsible. It queries all admin units.

    This listing is based on opengever.globalindex (sqlalchemy) and respects
    the basic features of tabbedview such as searching and batching.
    """

    filterlist = FilterList(
        Filter('filter_all', _('label_tabbedview_filter_all')),
        PendingMinusResolvedTasksFilter('filter_pending',
                                        _('label_pending', 'Pending'),
                                        default=True),
    )

    enabled_actions = [
        'pdf_taskslisting',
        'export_tasks',
    ]

    major_actions = [
        'pdf_taskslisting',
    ]

    def get_base_query(self):
        userid = api.user.get_current().getId()
        responsibles = [
            team.actor_id()
            for team in Team.query.join(Group).join(groups_users).filter_by(
                userid=userid)
        ]
        responsibles.append(userid)

        return Task.query.by_responsibles(responsibles)
Ejemplo n.º 6
0
class ProposalListingTab(FilteredListingTab):
    implements(IProposalTableSourceConfig)

    filterlist_name = 'proposal_state_filter'
    filterlist = FilterList(
        Filter('filter_proposals_all', _('all', default=u'All')),
        ActiveProposalFilter('filter_proposals_active',
                             _('active', default=u'Active'),
                             default=True),
        DecidedProposalFilter('filter_proposals_decided',
                              _('decided', default=u'Decided')))

    sort_on = ''
    show_selects = False

    @property
    def columns(self):
        return (
            {
                'column':
                'proposal_id',
                'column_title':
                _(u'label_proposal_id', default=u'Reference Number')
            },
            {
                'column':
                'decision_number',
                'column_title':
                _(u'label_decision_number', default=u'Decision number'),
                'transform':
                lambda item, value: item.get_decision_number()
            },
            {
                'column': 'title',
                'column_title': _(u'column_title', default=u'Title'),
                'transform': proposal_link
            },
            {
                'column': 'workflow_state',
                'column_title': _(u'column_state', default=u'State'),
                'transform': translated_state
            },
            {
                'column': 'committee_id',
                'column_title': _(u'column_comittee', default=u'Comittee'),
                'transform': lambda item, value: item.committee.get_link()
            },
            {
                'column': 'generated_meeting_link',
                'column_title': _(u'column_meeting', default=u'Meeting'),
                'transform': lambda item, value: item.get_meeting_link()
            },
        )

    def get_base_query(self):
        return Proposal.query.by_container(self.context,
                                           get_current_admin_unit())
Ejemplo n.º 7
0
class Organizations(OrganizationListingTab):
    sort_on = 'name'

    show_selects = False
    filterlist_name = 'organization_state_filter'
    filterlist_available = True
    filterlist = FilterList(
        Filter('filter_all', tmf('label_tabbedview_filter_all')),
        ActiveOnlyFilter('filter_active', tmf('Active'), default=True))

    enabled_actions = []
    major_actions = []
Ejemplo n.º 8
0
class Persons(PersonListingTab):
    sort_on = 'lastname'

    show_selects = False
    filterlist_name = 'person_state_filter'
    filterlist_available = True
    filterlist = FilterList(
        Filter('filter_all', tmf('all')),
        ActiveOnlyFilter('filter_active', tmf('Active'), default=True))

    enabled_actions = []
    major_actions = []
Ejemplo n.º 9
0
    def setUp(self):
        super(TestFilterList, self).setUp()

        self.filter_all = Filter('filter_all', 'All')
        self.filter_active = CatalogQueryFilter(
            'filter_active', 'Active', default=True,
            query_extension={'review_state': ['state-open']})
        self.filter_closed = CatalogQueryFilter(
            'filter_closed', 'Closed',
            query_extension={'review_state': ['state-closed']})

        self.filter_list = FilterList(
            self.filter_all, self.filter_active, self.filter_closed)
Ejemplo n.º 10
0
class Committees(grok.View, GeverTabMixin):
    grok.name('tabbedview_view-committees')
    grok.context(ICommitteeContainer)
    grok.require('zope2.View')
    grok.template('committee')

    filterlist_name = 'committee_state_filter'
    filterlist_available = True
    filterlist = FilterList(
        Filter('filter_all', tmf('all')),
        ActiveOnlyFilter('filter_active', tmf('Active'), default=True))

    def __call__(self):
        self.selected_filter_id = self.request.get(self.filterlist_name)
        return super(Committees, self).__call__()

    def extend_query_with_statefilter(self, query):
        return self.filterlist.update_query(
            query, self.request.get(self.filterlist_name))

    def committees(self):
        committees = []
        filter = self.get_filter_text()
        query = Committee.query.order_by(Committee.title)
        query = query.by_searchable_text(text_filters=filter)
        query = self.extend_query_with_statefilter(query)

        for committee in query.all():
            content_obj = committee.resolve_committee()
            if not content_obj:
                continue
            if not api.user.has_permission('View', obj=content_obj):
                continue

            committees.append({
                'title':
                committee.title,
                'url':
                committee.get_url(),
                'state_class':
                'active' if committee.is_active() else 'inactive',
                'number_unscheduled_proposals':
                len(meeting_service().get_submitted_proposals(committee)),
                'next_meeting':
                Meeting.query.get_next_meeting(committee),
                'last_meeting':
                Meeting.query.get_last_meeting(committee)
            })

        return committees
Ejemplo n.º 11
0
class Organizations(OrganizationListingTab):
    grok.name('tabbedview_view-organizations')
    grok.context(IContactFolder)

    sort_on = 'name'

    show_selects = False
    filterlist_name = 'organization_state_filter'
    filterlist_available = True
    filterlist = FilterList(
        Filter('filter_all', tmf('all')),
        ActiveOnlyFilter('filter_active', tmf('Active'), default=True))

    enabled_actions = []
    major_actions = []
class MembershipListingTab(FilteredListingTab):
    implements(IMembershipTableSourceConfig)

    filterlist_name = 'membership_state_filter'
    filterlist = FilterList(
        Filter('filter_membership_all', _('all', default=u'All')),
        ActiveMembershipFilter('filter_membership_active',
                               _('active', default=u'Active'),
                               default=True))

    show_selects = False

    model = Membership
    sqlalchemy_sort_indexes = {'member_id': Member.fullname}
    sort_on = 'member_id'

    @property
    def columns(self):
        return (
            {
                'column': 'member_id',
                'column_title': _(u'column_member', default=u'Member'),
                'transform': self.get_member_link
            },
            {
                'column': 'date_from',
                'column_title': _(u'column_date_from', default=u'Date from'),
                'transform': lambda item, value: item.format_date_from()
            },
            {
                'column': 'date_to',
                'column_title': _(u'column_date_to', default=u'Date to'),
                'transform': lambda item, value: item.format_date_to()
            },
            {
                'column': 'role',
                'column_title': _(u'column_role', default=u'Role'),
                'transform': lambda item, value: item.role
            },
        )

    def get_base_query(self):
        return Membership.query.filter_by(
            committee=self.context.load_model()).join(Membership.member)

    def get_member_link(self, item, value):
        return item.member.get_link(aq_parent(aq_inner(self.context)))
Ejemplo n.º 13
0
class Dispositions(BaseCatalogListingTab):
    grok.name('tabbedview_view-dispositions')

    types = ['opengever.disposition.disposition']
    enabled_actions = []
    major_actions = []

    filterlist_name = 'disposition_state_filter'
    filterlist_available = True
    filterlist = FilterList(
        Filter('filter_all', _('all')),
        CatalogQueryFilter('filter_active',
                           _('active'),
                           default=True,
                           query_extension={'review_state': ACTIVE_STATES}))

    columns = (
        {
            'column': '',
            'column_title': '',
            'transform': path_checkbox,
            'sortable': False,
            'width': 30
        },
        {
            'column':
            'sequence_number',
            'column_title':
            _(u'document_sequence_number', default=u'Sequence Number'),
            'sort_index':
            'sequence_number'
        },
        {
            'column': 'Title',
            'column_title': _(u'label_title', default=u'Title'),
            'sort_index': 'sortable_title',
            'transform': linked
        },
        {
            'column': 'review_state',
            'column_title': _(u'label_review_state', default=u'Review state'),
            'transform': workflow_state
        },
    )
Ejemplo n.º 14
0
class TeamsListing(BaseListingTab):
    """Tab registered on contacts folder listing all teams.
    """

    implements(ITeamListingTableSourceConfig)

    sort_on = 'title'
    sort_order = ''

    # the model attributes is used for a dynamic textfiltering functionality
    model = Team
    show_selects = False

    filterlist_name = 'team_state_filter'
    filterlist_available = True
    filterlist = FilterList(
        Filter('filter_all', _('label_tabbedview_filter_all')),
        ActiveOnlyFilter('filter_active', _('Active'), default=True))

    columns = ({
        'column': 'title',
        'column_title': _(u'label_title', default=u'Title'),
        'transform': linked_title_helper
    }, {
        'column': 'groupid',
        'column_title': _(u'label_group', default=u'Group'),
        'transform': lambda item, value: item.group.label()
    }, {
        'column': 'org_unit_id',
        'column_title': _(u'label_org_unit', default=u'Org Unit'),
        'transform': lambda item, value: item.org_unit.title
    }, {
        'column': 'active',
        'column_title': _(u'label_active', default=u'Active'),
        'transform': boolean_helper
    })

    def get_base_query(self):
        """Returns the base search query (sqlalchemy)
        """
        session = create_session()
        return session.query(Team)
Ejemplo n.º 15
0
 def filterlist(self):
     return FilterList(self.all_filter, self.active_filter)
Ejemplo n.º 16
0
class UsersListing(BaseListingTab):
    """Tab registered on contacts folder (see opengever.contact) listing all
    users.
    """
    implements(IUsersListingTableSourceConfig)

    sort_on = 'lastname'
    sort_order = ''

    # the model attributes is used for a dynamic textfiltering functionality
    model = User
    show_selects = False

    filterlist_name = 'user_state_filter'
    filterlist_available = True
    filterlist = FilterList(
        Filter('filter_all', _('label_tabbedview_filter_all')),
        ActiveOnlyFilter('filter_active', _('Active'), default=True))

    columns = (
        {
            'column': 'lastname',
            'column_title': _(u'label_userstab_lastname', default=u'Lastname'),
            'transform': linked_user_helper
        },
        {
            'column': 'firstname',
            'column_title': _(u'label_userstab_firstname',
                              default=u'Firstname'),
            'transform': linked_user_helper
        },
        {
            'column': 'userid',
            'column_title': _(u'label_userstab_userid', default=u'Userid'),
            'transform': linked_user_helper
        },
        {
            'column': 'email',
            'column_title': _(u'label_userstab_email', default=u'Email'),
            'transform': email_helper
        },
        {
            'column':
            'phone_office',
            'column_title':
            _(u'label_userstab_phone_office', default=u'Office Phone')
        },
        {
            'column': 'department',
            'column_title': _(u'label_department_user', default=u'Department')
        },
        {
            'column': 'directorate',
            'column_title': _(u'label_directorate_user',
                              default=u'Directorate')
        },
        {
            'column': 'active',
            'column_title': _(u'label_active', default=u'Active'),
            'transform': boolean_helper
        },
    )

    def get_base_query(self):
        """Returns the base search query (sqlalchemy)
        """
        session = create_session()
        return session.query(User)
Ejemplo n.º 17
0
class TestFilterList(TestCase):

    def setUp(self):
        super(TestFilterList, self).setUp()

        self.filter_all = Filter('filter_all', 'All')
        self.filter_active = CatalogQueryFilter(
            'filter_active', 'Active', default=True,
            query_extension={'review_state': ['state-open']})
        self.filter_closed = CatalogQueryFilter(
            'filter_closed', 'Closed',
            query_extension={'review_state': ['state-closed']})

        self.filter_list = FilterList(
            self.filter_all, self.filter_active, self.filter_closed)

    def test_get_by_filter_id(self):
        self.assertEquals(
            self.filter_all, self.filter_list['filter_all'])

        self.assertEquals(
            self.filter_active, self.filter_list['filter_active'])

    def test_default_filter(self):
        self.assertEquals(self.filter_active, self.filter_list.default_filter)

    def test_only_one_default_filter_possible(self):
        with self.assertRaises(ValueError) as cm:
            FilterList(Filter('all', 'All', default=True),
                       Filter('active', 'Active', default=True))

        self.assertEquals(
            'Only one filter marked as default possible.',
            str(cm.exception))

    def test_filters_are_ordered(self):
        self.assertEquals(
            [self.filter_all, self.filter_active, self.filter_closed],
            self.filter_list.filters())

    def test_is_active_when_id_matchs(self):
        selected_filter_id = 'filter_all'

        self.assertTrue(self.filter_all.is_active(selected_filter_id))
        self.assertFalse(self.filter_active.is_active(selected_filter_id))
        self.assertFalse(self.filter_closed.is_active(selected_filter_id))

    def test_is_active_when_its_the_default_and_currently_no_filter_is_selected(self):
        selected_filter_id = None

        self.assertFalse(self.filter_all.is_active(selected_filter_id))
        self.assertTrue(self.filter_active.is_active(selected_filter_id))
        self.assertFalse(self.filter_closed.is_active(selected_filter_id))

    def test_update_query_by_selected_filter(self):
        selected_filter_id = 'filter_closed'

        self.assertEquals(
            {'review_state': ['state-closed']},
            self.filter_list.update_query({}, selected_filter_id))

    def test_update_query_by_default_filter_when_no_filter_is_selected(self):
        selected_filter_id = None

        self.assertEquals(
            {'review_state': ['state-open']},
            self.filter_list.update_query({}, selected_filter_id))
Ejemplo n.º 18
0
class TestFilterList(TestCase):
    def setUp(self):
        super(TestFilterList, self).setUp()

        self.filter_all = Filter('filter_all', 'All')
        self.filter_active = CatalogQueryFilter(
            'filter_active',
            'Active',
            default=True,
            query_extension={'review_state': ['state-open']})
        self.filter_closed = CatalogQueryFilter(
            'filter_closed',
            'Closed',
            query_extension={'review_state': ['state-closed']})

        self.filter_list = FilterList(self.filter_all, self.filter_active,
                                      self.filter_closed)

    def test_get_by_filter_id(self):
        self.assertEquals(self.filter_all, self.filter_list['filter_all'])

        self.assertEquals(self.filter_active,
                          self.filter_list['filter_active'])

    def test_default_filter(self):
        self.assertEquals(self.filter_active, self.filter_list.default_filter)

    def test_only_one_default_filter_possible(self):
        with self.assertRaises(ValueError) as cm:
            FilterList(Filter('all', 'All', default=True),
                       Filter('active', 'Active', default=True))

        self.assertEquals('Only one filter marked as default possible.',
                          str(cm.exception))

    def test_filters_are_ordered(self):
        self.assertEquals(
            [self.filter_all, self.filter_active, self.filter_closed],
            self.filter_list.filters())

    def test_is_active_when_id_matchs(self):
        selected_filter_id = 'filter_all'

        self.assertTrue(self.filter_all.is_active(selected_filter_id))
        self.assertFalse(self.filter_active.is_active(selected_filter_id))
        self.assertFalse(self.filter_closed.is_active(selected_filter_id))

    def test_is_active_when_its_the_default_and_currently_no_filter_is_selected(
            self):
        selected_filter_id = None

        self.assertFalse(self.filter_all.is_active(selected_filter_id))
        self.assertTrue(self.filter_active.is_active(selected_filter_id))
        self.assertFalse(self.filter_closed.is_active(selected_filter_id))

    def test_update_query_by_selected_filter(self):
        selected_filter_id = 'filter_closed'

        self.assertEquals({'review_state': ['state-closed']},
                          self.filter_list.update_query({},
                                                        selected_filter_id))

    def test_update_query_by_default_filter_when_no_filter_is_selected(self):
        selected_filter_id = None

        self.assertEquals({'review_state': ['state-open']},
                          self.filter_list.update_query({},
                                                        selected_filter_id))
Ejemplo n.º 19
0
class GlobalTaskListingTab(BaseListingTab):
    """A tabbed view mixin which brings support for listing tasks from
    the SQL (globally over all clients).

    There is support for searching, batching and ordering.
    """

    implements(IGlobalTaskTableSourceConfig)

    template = ViewPageTemplateFile("generic_with_filters.pt")

    sort_on = 'modified'
    sort_reverse = False
    #lazy must be false otherwise there will be no correct batching
    lazy = False

    # the model attribute is used for a dynamic textfiltering functionality
    model = Task
    enabled_actions = []
    major_actions = []

    select_all_template = ViewPageTemplateFile('select_all_globaltasks.pt')

    filterlist_name = 'task_state_filter'
    filterlist_available = True

    filterlist = FilterList(
        Filter('filter_all', _('label_tabbedview_filter_all')),
        PendingTasksFilter('filter_pending',
                           _('label_pending', 'Pending'),
                           default=True),
    )

    columns = (
        {
            'column': '',
            'sortable': False,
            'transform': task_id_checkbox_helper,
            'width': 30
        },
        {
            'column': 'review_state',
            'column_title': _(u'column_review_state', default=u'Review state'),
            'transform': workflow_state
        },
        {
            'column': 'title',
            'column_title': _(u'column_title', default=u'Title'),
            'transform': indexed_task_link_helper
        },
        {
            'column': 'task_type',
            'column_title': _(u'column_task_type', default=u'Task type'),
            'transform': task_type_helper
        },
        {
            'column': 'deadline',
            'column_title': _(u'column_deadline', default=u'Deadline'),
            'transform': lambda task, deadline: task.get_deadline_label()
        },
        {
            'column':
            'completed',
            'column_title':
            _(u'column_date_of_completion', default=u'Date of completion'),
            'transform':
            readable_date_set_invisibles
        },
        {
            'column': 'responsible',
            'column_title': _(u'label_responsible_task',
                              default=u'Responsible'),
            'transform': readable_ogds_author
        },
        {
            'column': 'issuer',
            'column_title': _(u'label_issuer', default=u'Issuer'),
            'transform': readable_ogds_author
        },
        {
            'column': 'created',
            'column_title': _(u'column_issued_at', default=u'Issued at'),
            'transform': helper.readable_date
        },
        {
            'column': 'containing_dossier',
            'column_title': _('containing_dossier', 'Dossier'),
            'transform': linked_containing_maindossier
        },
        {
            'column':
            'issuing_org_unit',
            'column_title':
            _('column_issuing_org_unit', default=u'Organisational Unit'),
            'transform':
            org_unit_title_helper,
            'condition':
            display_org_unit_title_condition
        },
        {
            'column':
            'sequence_number',
            'column_title':
            _(u'column_sequence_number', default=u'Sequence number')
        },
    )
Ejemplo n.º 20
0
class ProposalListingTab(FilteredListingTab):
    implements(IProposalTableSourceConfig)

    filterlist_name = 'proposal_state_filter'
    filterlist = FilterList(
        Filter(
            'filter_proposals_all',
            _('all', default=u'All')),
        ActiveProposalFilter(
            'filter_proposals_active',
            _('active', default=u'Active'),
            default=True),
        DecidedProposalFilter(
            'filter_proposals_decided',
            _('decided', default=u'Decided'))
        )

    sort_on = ''
    show_selects = False

    @property
    def columns(self):
        return (
            {'column': 'decision_number',
             'column_title': _(u'label_decision_number',
                               default=u'Decision number'),
             'transform': lambda item, value: item.get_decision_number(),
             'sortable': False,
             'groupable': False,
             'width': 80},

            {'column': 'title',
             'column_title': _(u'column_title', default=u'Title'),
             'transform': proposal_link,
             'sortable': True,
             'groupable': False,
             'width': 180},

            {'column': 'description',
             'column_title': _(u'column_description', default=u'Description'),
             'transform': get_description,
             'sortable': True,
             'groupable': False,
             'width': 180},

            {'column': 'workflow_state',
             'column_title': _(u'column_state', default=u'State'),
             'transform': translated_state,
             'width': 120},

            {'column': 'committee_id',
             'column_title': _(u'column_comittee', default=u'Comittee'),
             'transform': lambda item, value: item.committee.get_link(),
             'width': 180},

            {'column': 'generated_meeting_link',
             'column_title': _(u'column_meeting', default=u'Meeting'),
             'transform': lambda item, value: item.get_meeting_link(),
             'sortable': False,
             'groupable': False,
             'width': 180},

            {'column': 'date_of_submission',
             'column_title': _(u'column_date_of_submission',
                               default=u'Date of submission'),
             'transform': helper.readable_date,
             'sortable': True,
             'groupable': True,
             'width': 120},

            {'column': 'issuer',
             'column_title': _(u'label_issuer',
                               default=u'Issuer'),
             'transform': linked_ogds_author,
             'sortable': True,
             'groupable': True,
             'width': 200},

        )

    def get_base_query(self):
        return Proposal.query.by_container(
            self.context, get_current_admin_unit())