Exemplo n.º 1
0
    def __init__(self, *args, **kwargs):
        from .views import StockLevelsView
        domain = kwargs.pop('domain')
        self.helper = FormHelper()
        self.helper.form_class = 'form-horizontal'
        self.helper.label_class = 'col-sm-3 col-md-4 col-lg-2'
        self.helper.field_class = 'col-sm-4 col-md-5 col-lg-3'

        self.helper.layout = Layout(
            Fieldset(_('Stock Levels'), 'stock_emergency_level',
                     'stock_understock_threshold', 'stock_overstock_threshold')
            if not LOCATION_TYPE_STOCK_RATES.enabled(domain) else None,
            Fieldset(
                _('Consumption Settings'),
                PrependedText('use_auto_consumption', ''),
                'consumption_min_transactions',
                'consumption_min_window',
                'consumption_optimal_window',
                PrependedText('individual_consumption_defaults', ''),
            ),
            Fieldset(
                _('Phone Settings'),
                PrependedText('sync_consumption_fixtures', ''),
            ),
            hqcrispy.FormActions(
                ButtonHolder(Submit('submit', ugettext_lazy('Submit')))))

        from corehq.apps.locations.views import LocationImportView
        url = reverse(LocationImportView.urlname, args=[domain])

        forms.Form.__init__(self, *args, **kwargs)

        self.fields['individual_consumption_defaults'].help_text = _(
            "This is configured by <a href='{url}'>bulk importing your organization structure</a>."
        ).format(url=url)
Exemplo n.º 2
0
def stock_level_config_for_domain(domain, commtrack_enabled):
    from corehq.apps.commtrack.models import CommtrackConfig
    ct_config = CommtrackConfig.for_domain(domain)
    if ((ct_config is None) or (not commtrack_enabled)
            or LOCATION_TYPE_STOCK_RATES.enabled(domain)):
        return None
    else:
        return ct_config.stock_levels_config
Exemplo n.º 3
0
 def _populate_stock_levels(self):
     from corehq.apps.commtrack.models import CommtrackConfig
     ct_config = CommtrackConfig.for_domain(self.domain)
     if ((ct_config is None) or (not self.commtrack_enabled)
             or LOCATION_TYPE_STOCK_RATES.enabled(self.domain)):
         return
     config = ct_config.stock_levels_config
     self.emergency_level = config.emergency_level
     self.understock_threshold = config.understock_threshold
     self.overstock_threshold = config.overstock_threshold
Exemplo n.º 4
0
def stock_level_config_for_domain(domain, commtrack_enabled):
    from corehq.apps.commtrack.models import CommtrackConfig
    ct_config = CommtrackConfig.for_domain(domain)
    if (
        (ct_config is None) or
        (not commtrack_enabled) or
        LOCATION_TYPE_STOCK_RATES.enabled(domain)
    ):
        return None
    else:
        return ct_config.stock_levels_config
Exemplo n.º 5
0
 def _populate_stock_levels(self):
     from corehq.apps.commtrack.models import CommtrackConfig
     ct_config = CommtrackConfig.for_domain(self.domain)
     if (
         (ct_config is None)
         or (not Domain.get_by_name(self.domain).commtrack_enabled)
         or LOCATION_TYPE_STOCK_RATES.enabled(self.domain)
     ):
         return
     config = ct_config.stock_levels_config
     self.emergency_level = config.emergency_level
     self.understock_threshold = config.understock_threshold
     self.overstock_threshold = config.overstock_threshold
Exemplo n.º 6
0
    def __init__(self, *args, **kwargs):
        from .views import StockLevelsView
        domain = kwargs.pop('domain')
        self.helper = FormHelper()
        self.helper.form_class = 'form-horizontal'
        self.helper.label_class = 'col-sm-3 col-md-4 col-lg-2'
        self.helper.field_class = 'col-sm-4 col-md-5 col-lg-3'

        self.helper.layout = Layout(
            Fieldset(
                _('Stock Levels'),
                'stock_emergency_level',
                'stock_understock_threshold',
                'stock_overstock_threshold'
            ) if not LOCATION_TYPE_STOCK_RATES.enabled(domain) else Fieldset(
                _('Stock Levels'),
                ButtonHolder(
                    HTML('<a href="{}" class="btn btn-primary">{}</a>'.format(
                        reverse(StockLevelsView.urlname, args=[domain]),
                        _('Configure Stock Levels')))),
            ),
            Fieldset(
                _('Consumption Settings'),
                PrependedText('use_auto_consumption', ''),
                'consumption_min_transactions',
                'consumption_min_window',
                'consumption_optimal_window',
                PrependedText('individual_consumption_defaults', ''),
            ),
            Fieldset(
                _('Phone Settings'),
                PrependedText('sync_consumption_fixtures', ''),
            ),
            hqcrispy.FormActions(
                ButtonHolder(
                    Submit('submit', ugettext_lazy('Submit'))
                )
            )
        )

        from corehq.apps.locations.views import LocationImportView
        url = reverse(
            LocationImportView.urlname, args=[domain]
        )

        forms.Form.__init__(self, *args, **kwargs)

        self.fields['individual_consumption_defaults'].help_text = _(
            "This is configured by <a href='{url}'>bulk importing your organization structure</a>."
        ).format(url=url)
Exemplo n.º 7
0
    def __init__(self, *args, **kwargs):
        from .views import StockLevelsView
        domain = kwargs.pop('domain')
        self.helper = FormHelper()
        self.helper.form_class = 'form-horizontal'
        self.helper.layout = Layout(
            Fieldset(
                _('Stock Levels'),
                'stock_emergency_level',
                'stock_understock_threshold',
                'stock_overstock_threshold'
            ) if not LOCATION_TYPE_STOCK_RATES.enabled(domain) else Fieldset(
                _('Stock Levels'),
                ButtonHolder(
                    HTML('<a href="{}" class="btn btn-primary">{}</a>'.format(
                        reverse(StockLevelsView.urlname, args=[domain]),
                        _('Configure Stock Levels')))),
            ),
            Fieldset(
                _('Consumption Settings'),
                'use_auto_consumption',
                'consumption_min_transactions',
                'consumption_min_window',
                'consumption_optimal_window',
                'individual_consumption_defaults',
            ),
            Fieldset(
                _('Phone Settings'),
                'sync_consumption_fixtures',
            ),
            ButtonHolder(
                Submit('submit', ugettext_lazy('Submit'))
            )
        )

        from corehq.apps.locations.views import LocationImportView
        url = reverse(
            LocationImportView.urlname, args=[domain]
        )

        forms.Form.__init__(self, *args, **kwargs)

        self.fields['individual_consumption_defaults'].help_text = _(
            "This is configured on the <a href='{url}'>bulk location import page</a>."
        ).format(url=url)