Example #1
0
	def refresh(self, lctrl=None):
		orgs = gmOrganization.get_orgs(order_by = 'organization, l10n_category')
		items = [ [o['organization'], o['l10n_category'], o['pk_org']] for o in orgs ]
		self._LCTRL_items.set_string_items(items)
		self._LCTRL_items.set_column_widths(widths = [wx.LIST_AUTOSIZE, wx.LIST_AUTOSIZE, wx.LIST_AUTOSIZE])
		self._LCTRL_items.set_data(orgs)

		for idx in range(len(orgs)):
			org = orgs[idx]
			if org['is_praxis']:
				self._LCTRL_items.SetItemTextColour(idx, col=wx.NamedColour('RED'))
				break
Example #2
0
	def refresh(self, lctrl=None):
		orgs = gmOrganization.get_orgs(order_by = 'organization, l10n_category')
		items = [ [o['organization'], o['l10n_category'], o['pk_org']] for o in orgs ]
		self._LCTRL_items.set_string_items(items)
		self._LCTRL_items.set_column_widths(widths = [wx.LIST_AUTOSIZE, wx.LIST_AUTOSIZE, wx.LIST_AUTOSIZE])
		self._LCTRL_items.set_data(orgs)

		for idx in range(len(orgs)):
			org = orgs[idx]
			if org['is_praxis']:
				self._LCTRL_items.SetItemTextColour(idx, col=wx.Colour('RED'))
				break
Example #3
0
def set_active_praxis_branch(parent=None, no_parent=False):

    if no_parent:
        parent = None
    else:
        if parent is None:
            parent = wx.GetApp().GetTopWindow()

    branches = gmPraxis.get_praxis_branches()

    if len(branches) == 1:
        _log.debug('only one praxis branch configured')
        gmPraxis.gmCurrentPraxisBranch(branches[0])
        return True

    if len(branches) == 0:
        orgs = gmOrganization.get_orgs()
        if len(orgs) == 0:
            pk_cat = gmOrganization.create_org_category(category=u'Praxis')
            org = gmOrganization.create_org(_('Your praxis'), pk_cat)
            unit = org.add_unit(_('Your branch'))
            branch = gmPraxis.create_praxis_branch(
                pk_org_unit=unit['pk_org_unit'])
            _log.debug(
                'auto-created praxis branch because no organizations existed: %s',
                branch)
            gmPraxis.gmCurrentPraxisBranch(branch)
            gmGuiHelpers.gm_show_info(
                title=_('Praxis configuration ...'),
                info=_('GNUmed has auto-created the following\n'
                       'praxis branch for you (which you can\n'
                       'later configure as needed):\n'
                       '\n'
                       '%s') % branch.format())
            return True

        if len(orgs) == 1:
            units = orgs[0].units
            if len(units) == 1:
                branch = gmPraxis.create_praxis_branch(
                    pk_org_unit=units[0]['pk_org_unit'])
                _log.debug(
                    'auto-selected praxis branch because only one organization with only one unit existed: %s',
                    branch)
                gmPraxis.gmCurrentPraxisBranch(branch)
                gmGuiHelpers.gm_show_info(
                    title=_('Praxis configuration ...'),
                    info=_('GNUmed has auto-selected the following\n'
                           'praxis branch for you (which you can\n'
                           'later configure as needed):\n'
                           '\n'
                           '%s') % branch.format())
                return True

        _log.debug(
            'no praxis branches configured, selecting from organization units')
        msg = _(
            'No praxis branches configured currently.\n'
            '\n'
            'You MUST select one unit of an organization to be the initial\n'
            'branch (site, office) which you are logging in from.')
        unit = gmOrganizationWidgets.select_org_unit(msg=msg, no_parent=True)
        if unit is None:
            _log.warning('no organization unit selected, aborting')
            return False
        _log.debug('org unit selected as praxis branch: %s', unit)
        branch = gmPraxis.create_praxis_branch(pk_org_unit=unit['pk_org_unit'])
        _log.debug('created praxis branch: %s', branch)
        gmPraxis.gmCurrentPraxisBranch(branch)
        return True

    #--------------------
    def refresh(lctrl):
        branches = gmPraxis.get_praxis_branches()
        items = [[b['branch'],
                  gmTools.coalesce(b['l10n_unit_category'], u'')]
                 for b in branches]
        lctrl.set_string_items(items=items)
        lctrl.set_data(data=branches)

    #--------------------
    branch = gmListWidgets.get_choices_from_list(
        parent=parent,
        msg=_(
            "Select the branch of praxis [%s] which you are logging in from.\n"
        ) % branches[0]['praxis'],
        caption=_('Praxis branch selection ...'),
        columns=[_('Branch'), _('Branch type')],
        can_return_empty=False,
        single_selection=True,
        refresh_callback=refresh)
    if branch is None:
        _log.warning('no praxis branch selected, aborting')
        return False
    gmPraxis.gmCurrentPraxisBranch(branch)
    return True
Example #4
0
def set_active_praxis_branch(parent=None, no_parent=False):

    if no_parent:
        parent = None
    else:
        if parent is None:
            parent = wx.GetApp().GetTopWindow()

    branches = gmPraxis.get_praxis_branches()

    if len(branches) == 1:
        _log.debug('only one praxis branch configured, activating')
        gmPraxis.gmCurrentPraxisBranch(branches[0])
        return True

    if len(branches) == 0:
        orgs = gmOrganization.get_orgs()
        if len(orgs) == 0:
            new_branch_of_new_praxis = __create_praxis_and_branch()
            gmPraxis.gmCurrentPraxisBranch(new_branch_of_new_praxis)
            return True

        if len(orgs) == 1:
            units = orgs[0].units
            if len(units) == 1:
                branch = __create_branch_for_praxis(units[0]['pk_org_unit'])
                gmPraxis.gmCurrentPraxisBranch(branch)
                return True

        branch = __select_org_unit_as_branch()
        if branch is None:
            return False

        gmPraxis.gmCurrentPraxisBranch(branch)
        return True

    most_recent_branch = __get_most_recently_selected_branch()

    #--------------------
    def refresh(lctrl):
        branches = gmPraxis.get_praxis_branches()
        items = [[b['branch'],
                  gmTools.coalesce(b['l10n_unit_category'], '')]
                 for b in branches]
        lctrl.set_string_items(items=items)
        lctrl.set_data(data=branches)
        if most_recent_branch is not None:
            for idx in range(len(branches)):
                if branches[idx].format(one_line=True) == most_recent_branch:
                    lctrl.selections = [idx]
                    break

    #--------------------

    branch = gmListWidgets.get_choices_from_list(
        parent=parent,
        msg=_(
            "Select the branch of praxis [%s] which you are logging in from.\n"
        ) % branches[0]['praxis'],
        caption=_('Praxis branch selection ...'),
        columns=[_('Branch'), _('Branch type')],
        can_return_empty=False,
        single_selection=True,
        refresh_callback=refresh)
    if branch is None:
        _log.warning('no praxis branch selected, aborting')
        return False

    __update_most_recently_selected_branch(branch)
    gmPraxis.gmCurrentPraxisBranch(branch)
    return True
Example #5
0
def set_active_praxis_branch(parent=None, no_parent=False):

	if no_parent:
		parent = None
	else:
		if parent is None:
			parent = wx.GetApp().GetTopWindow()

	branches = gmPraxis.get_praxis_branches()

	if len(branches) == 1:
		_log.debug('only one praxis branch configured')
		gmPraxis.gmCurrentPraxisBranch(branches[0])
		return True

	if len(branches) == 0:
		orgs = gmOrganization.get_orgs()
		if len(orgs) == 0:
			pk_cat = gmOrganization.create_org_category(category = u'Praxis')
			org = gmOrganization.create_org(_('Your praxis'), pk_cat)
			unit = org.add_unit(_('Your branch'))
			branch = gmPraxis.create_praxis_branch(pk_org_unit = unit['pk_org_unit'])
			_log.debug('auto-created praxis branch because no organizations existed: %s', branch)
			gmPraxis.gmCurrentPraxisBranch(branch)
			gmGuiHelpers.gm_show_info (
				title = _('Praxis configuration ...'),
				info = _(
					'GNUmed has auto-created the following\n'
					'praxis branch for you (which you can\n'
					'later configure as needed):\n'
					'\n'
					'%s'
				) % branch.format()
			)
			return True

		if len(orgs) == 1:
			units = orgs[0].units
			if len(units) == 1:
				branch = gmPraxis.create_praxis_branch(pk_org_unit = units[0]['pk_org_unit'])
				_log.debug('auto-selected praxis branch because only one organization with only one unit existed: %s', branch)
				gmPraxis.gmCurrentPraxisBranch(branch)
				gmGuiHelpers.gm_show_info (
					title = _('Praxis configuration ...'),
					info = _(
						'GNUmed has auto-selected the following\n'
						'praxis branch for you (which you can\n'
						'later configure as needed):\n'
						'\n'
						'%s'
					) % branch.format()
				)
				return True

		_log.debug('no praxis branches configured, selecting from organization units')
		msg = _(
				'No praxis branches configured currently.\n'
				'\n'
				'You MUST select one unit of an organization to be the initial\n'
				'branch (site, office) which you are logging in from.'
		)
		unit = gmOrganizationWidgets.select_org_unit(msg = msg, no_parent = True)
		if unit is None:
			_log.warning('no organization unit selected, aborting')
			return False
		_log.debug('org unit selected as praxis branch: %s', unit)
		branch = gmPraxis.create_praxis_branch(pk_org_unit = unit['pk_org_unit'])
		_log.debug('created praxis branch: %s', branch)
		gmPraxis.gmCurrentPraxisBranch(branch)
		return True

	#--------------------
	def refresh(lctrl):
		branches = gmPraxis.get_praxis_branches()
		items = [
			[	b['branch'],
				gmTools.coalesce(b['l10n_unit_category'], u'')
			] for b in branches
		]
		lctrl.set_string_items(items = items)
		lctrl.set_data(data = branches)
	#--------------------
	branch = gmListWidgets.get_choices_from_list (
		parent = parent,
		msg = _("Select branch (of praxis [%s]) which you are logging in from.\n") % branches[0]['praxis'],
		caption = _('Praxis branch selection ...'),
		columns = [_('Branch'), _('Branch type')],
		can_return_empty = False,
		single_selection = True,
		refresh_callback = refresh
	)
	if branch is None:
		_log.warning('no praxis branch selected, aborting')
		return False
	gmPraxis.gmCurrentPraxisBranch(branch)
	return True