コード例 #1
0
ファイル: gmPraxisWidgets.py プロジェクト: ncqgm/gnumed
def __create_branch_for_praxis(pk_org_unit: int):
    branch = gmPraxis.create_praxis_branch(pk_org_unit=pk_org_unit)
    _log.debug(
        'auto-created praxis branch because only one organization without any unit existed: %s',
        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 branch
コード例 #2
0
ファイル: gmPraxisWidgets.py プロジェクト: ncqgm/gnumed
def __create_praxis_and_branch():
    pk_cat = gmOrganization.create_org_category(category='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 and branch because no organizations existed: %s',
        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 branch
コード例 #3
0
ファイル: gmPraxisWidgets.py プロジェクト: ncqgm/gnumed
def __select_org_unit_as_branch():
    _log.debug(
        'no praxis branches configured, selecting from organization units')
    msg = _('No praxis branches configured currently.\n'
            '\n'
            'You MUST select one unit of one organization to be the\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 None

    _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 from org unit: %s', branch)
    return branch
コード例 #4
0
ファイル: gmPraxisWidgets.py プロジェクト: jeromecc/gnumed
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
コード例 #5
0
ファイル: gmPraxisWidgets.py プロジェクト: sk/gnumed
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