def lookups(self, request, queryset): from apps.accounts.models import Hostingprovider qs = Hostingprovider.objects.all().values_list( 'country', flat=True).distinct().order_by('country') countries = [(country, COUNTRIES.get(country, 'Unknown Country')) for country in qs] return countries
def __init__(self, account, domain, creating_user, data=None, *args, **kwargs): super(ConfirmExtraUserChargesForm, self).__init__(account, domain, creating_user, data=data, *args, **kwargs) from corehq.apps.users.views.mobile import MobileWorkerListView self.helper.label_class = 'col-sm-3 col-md-2' self.helper.field_class = 'col-sm-9 col-md-8 col-lg-6' self.helper.layout = crispy.Layout( crispy.Fieldset( _("Basic Information"), 'company_name', 'first_name', 'last_name', crispy.Field( 'email_list', css_class='input-xxlarge accounting-email-select2', data_initial=json.dumps(self.initial.get('email_list'))), 'phone_number', ), crispy.Fieldset( _("Mailing Address"), 'first_line', 'second_line', 'city', 'state_province_region', 'postal_code', crispy.Field( 'country', css_class="input-large accounting-country-select2", data_country_code=self.current_country or '', data_country_name=COUNTRIES.get(self.current_country, '')), ), hqcrispy.FormActions( crispy.HTML( '<a href="%(user_list_url)s" class="btn btn-default">%(text)s</a>' % { 'user_list_url': reverse(MobileWorkerListView.urlname, args=[self.domain]), 'text': _("Back to Mobile Workers List") }), StrictButton( _("Confirm Billing Information"), type="submit", css_class='btn btn-primary disabled', ), ), )
def check_ioc_countries(): """ Check if all IOC codes map to ISO codes correctly """ from django_countries.data import COUNTRIES print("Checking if all IOC codes map correctly") for key in ISO_TO_IOC: assert COUNTRIES.get(key), 'No ISO code for %s' % key print("Finished checking IOC codes")
def check_ioc_countries(): """ Check if all IOC codes map to ISO codes correctly """ from django_countries.data import COUNTRIES print("Checking if all IOC codes map correctly") for key in ISO_TO_IOC.keys(): assert COUNTRIES.get(key, '') != '', 'No ISO code for %s' % key print("Finished checking IOC codes")
def __init__(self, account, domain, creating_user, data=None, *args, **kwargs): super(ConfirmExtraUserChargesForm, self).__init__(account, domain, creating_user, data=data, *args, **kwargs) self.fields['confirm_product_agreement'].label = _( 'I have read and agree to the <a href="%(pa_url)s" target="_blank">' 'Software Product Subscription Agreement</a>.' ) % {'pa_url': reverse('product_agreement')} from corehq.apps.users.views.mobile import MobileWorkerListView self.helper.label_class = 'col-sm-3 col-md-2' self.helper.field_class = 'col-sm-9 col-md-8 col-lg-6' self.helper.layout = crispy.Layout( crispy.Fieldset( _("Basic Information"), 'company_name', 'first_name', 'last_name', crispy.Field('email_list', css_class='input-xxlarge'), 'phone_number', ), crispy.Fieldset( _("Mailing Address"), 'first_line', 'second_line', 'city', 'state_province_region', 'postal_code', crispy.Field('country', css_class="input-large", data_countryname=COUNTRIES.get(self.current_country, '')), ), hqcrispy.B3MultiField( '', crispy.Field('confirm_product_agreement'), ), hqcrispy.FormActions( crispy.HTML( '<a href="%(user_list_url)s" class="btn btn-default">%(text)s</a>' % { 'user_list_url': reverse(MobileWorkerListView.urlname, args=[self.domain]), 'text': _("Back to Mobile Workers List") } ), StrictButton( _("Confirm Billing Information"), type="submit", css_class='btn btn-primary disabled', disabled="disabled", css_id="submit-button-pa", ), crispy.HTML( '<p class="help-inline" id="submit-button-help-qa" style="vertical-align: ' 'top; margin-top: 5px; margin-bottom: 0px;">%s</p>' % _("Please agree to the Product Subscription " "Agreement above before continuing.") ), ), )
def __init__(self, account, domain, creating_user, data=None, *args, **kwargs): super(ConfirmExtraUserChargesForm, self).__init__(account, domain, creating_user, data=data, *args, **kwargs) self.fields['confirm_product_agreement'].label = _( 'I have read and agree to the <a href="%(pa_url)s" target="_blank">' 'Software Product Subscription Agreement</a>.' ) % {'pa_url': reverse('product_agreement')} from corehq.apps.users.views.mobile import MobileWorkerListView self.helper.label_class = 'col-sm-3 col-md-2' self.helper.field_class = 'col-sm-9 col-md-8 col-lg-6' self.helper.layout = crispy.Layout( crispy.Fieldset( _("Basic Information"), 'company_name', 'first_name', 'last_name', crispy.Field('email_list', css_class='input-xxlarge ko-email-select2'), 'phone_number', ), crispy.Fieldset( _("Mailing Address"), 'first_line', 'second_line', 'city', 'state_province_region', 'postal_code', crispy.Field('country', css_class="input-large ko-country-select2", data_countryname=COUNTRIES.get(self.current_country, '')), ), hqcrispy.B3MultiField( '', crispy.Field('confirm_product_agreement'), ), hqcrispy.FormActions( crispy.HTML( '<a href="%(user_list_url)s" class="btn btn-default">%(text)s</a>' % { 'user_list_url': reverse(MobileWorkerListView.urlname, args=[self.domain]), 'text': _("Back to Mobile Workers List") } ), StrictButton( _("Confirm Billing Information"), type="submit", css_class='btn btn-primary disabled', disabled="disabled", css_id="submit-button-pa", ), crispy.HTML( '<p class="help-inline" id="submit-button-help-qa" style="vertical-align: ' 'top; margin-top: 5px; margin-bottom: 0px;">%s</p>' % _("Please agree to the Product Subscription " "Agreement above before continuing.") ), ), )
def check_ioc_countries(verbosity=1): """ Check if all IOC codes map to ISO codes correctly """ from django_countries.data import COUNTRIES if verbosity: # pragma: no cover print("Checking if all IOC codes map correctly") for key in ISO_TO_IOC: assert COUNTRIES.get(key), "No ISO code for %s" % key if verbosity: # pragma: no cover print("Finished checking IOC codes")
def check_ioc_countries(verbosity=1): """ Check if all IOC codes map to ISO codes correctly """ from django_countries.data import COUNTRIES if verbosity: # pragma: no cover print("Checking if all IOC codes map correctly") for key in ISO_TO_IOC: assert COUNTRIES.get(key), 'No ISO code for %s' % key if verbosity: # pragma: no cover print("Finished checking IOC codes")
def __init__(self, account, domain, creating_user, data=None, *args, **kwargs): super(ConfirmExtraUserChargesForm, self).__init__(account, domain, creating_user, data=data, *args, **kwargs) self.fields["confirm_product_agreement"].label = _( 'I have read and agree to the <a href="%(pa_url)s" target="_blank">' "Software Product Subscription Agreement</a>." ) % {"pa_url": reverse("product_agreement")} from corehq.apps.users.views.mobile import MobileWorkerListView self.helper.layout = crispy.Layout( crispy.Fieldset( _("Basic Information"), "company_name", "first_name", "last_name", crispy.Field("emails", css_class="input-xxlarge"), "phone_number", ), crispy.Fieldset( _("Mailing Address"), "first_line", "second_line", "city", "state_province_region", "postal_code", crispy.Field( "country", css_class="input-large", data_countryname=COUNTRIES.get(self.current_country, "") ), ), crispy.Field("confirm_product_agreement"), FormActions( crispy.HTML( '<a href="%(user_list_url)s" class="btn">%(text)s</a>' % { "user_list_url": reverse(MobileWorkerListView.urlname, args=[self.domain]), "text": _("Back to Mobile Workers List"), } ), StrictButton( _("Confirm Billing Information"), type="submit", css_class="btn btn-primary disabled", disabled="disabled", css_id="submit-button-pa", ), crispy.HTML( '<p class="help-inline" id="submit-button-help-qa" style="vertical-align: ' 'top; margin-top: 5px; margin-bottom: 0px;">%s</p>' % _("Please agree to the Product Subscription " "Agreement above before continuing.") ), ), )
def check_ioc_countries(verbosity=1): """ Check if all IOC codes map to ISO codes correctly """ from django_countries.data import COUNTRIES if verbosity: # pragma: no cover print("Checking if all IOC codes map correctly") for key in ISO_TO_IOC: if not COUNTRIES.get(key): # pragma: no cover raise KeyError(f"No ISO code for {key}") if verbosity: # pragma: no cover print("Finished checking IOC codes")
def update_mozillian_profiles(queryset=None): """Sync MozillianProfile objects with mozillians.org""" if not queryset: queryset = MozillianProfile.objects.all() for mozillian in queryset: data = get_mozillian_by_email(mozillian.email) if not data: # Try to fetch by username data = get_mozillian_by_username(mozillian.mozillian_username) if not data: continue if 'country' in data: mozillian.country = COUNTRIES.get(data['country'].upper(), '').capitalize() if 'full_name' in data: mozillian.full_name = data['full_name'] else: mozillian.full_name = 'Private Mozillian' mozillian.email = data['email'] if 'city' in data: mozillian.city = data['city'] if 'ircname' in data: mozillian.ircname = data['ircname'] if 'photo' in data: mozillian.avatar_url = data['photo'] if 'bio' in data: mozillian.bio = data['bio'] mozillian.save() mozillian.tracking_groups.clear() groups = [] if 'groups' in data: for group in data['groups']: obj, created = MozillianGroup.objects.get_or_create(name=group) groups.append(obj) mozillian.tracking_groups = groups logger.debug('Mozillian succesfully updated.')
def __init__(self, account, domain, creating_user, data=None, *args, **kwargs): super(ConfirmExtraUserChargesForm, self).__init__(account, domain, creating_user, data=data, *args, **kwargs) from corehq.apps.users.views.mobile import MobileWorkerListView self.helper.label_class = 'col-sm-3 col-md-2' self.helper.field_class = 'col-sm-9 col-md-8 col-lg-6' self.helper.layout = crispy.Layout( crispy.Fieldset( _("Basic Information"), 'company_name', 'first_name', 'last_name', crispy.Field('email_list', css_class='input-xxlarge accounting-email-select2', data_initial=json.dumps(self.initial.get('email_list'))), 'phone_number', ), crispy.Fieldset( _("Mailing Address"), 'first_line', 'second_line', 'city', 'state_province_region', 'postal_code', crispy.Field('country', css_class="input-large accounting-country-select2", data_country_code=self.current_country or '', data_country_name=COUNTRIES.get(self.current_country, '')), ), hqcrispy.FormActions( crispy.HTML( '<a href="%(user_list_url)s" class="btn btn-default">%(text)s</a>' % { 'user_list_url': reverse(MobileWorkerListView.urlname, args=[self.domain]), 'text': _("Back to Mobile Workers List") } ), StrictButton( _("Confirm Billing Information"), type="submit", css_class='btn btn-primary disabled', ), ), )
def get_gir_dict_for_domain_and_monthspan(domain, monthspan): user_tuple = GIRTableGenerator.classify_users(domain, monthspan) max_device = GIRTableGenerator.get_max_device(domain, monthspan) possible_experience = get_possibly_experienced(domain, monthspan) recently_active = GIRTableGenerator.get_active_recent(domain, monthspan) gir_dict = { 'month': monthspan.startdate, 'domain_name': domain.name, 'country': ', '.join([unicode(COUNTRIES.get(abbr, abbr)) for abbr in domain.deployment.countries]), 'sector': domain.internal.area, 'subsector': domain.internal.sub_area, 'bu': GIRTableGenerator.get_bu(domain), 'self_service': domain.internal.self_started, 'test_domain': TEST_COUCH_TO_SQL_MAP.get(domain.is_test, NOT_SET), 'start_date': domain.date_created, 'device_id': max_device, 'wam': AMPLIFY_COUCH_TO_SQL_MAP.get(domain.internal.amplifies_workers, NOT_SET), 'pam': AMPLIFY_COUCH_TO_SQL_MAP.get(domain.internal.amplifies_project, NOT_SET), 'wams_current': len(user_tuple.performing & user_tuple.experienced), 'active_users': len(user_tuple.active | user_tuple.sms), 'using_and_performing': len(user_tuple.performing), 'not_performing': len(user_tuple.active - user_tuple.performing), 'inactive_experienced': len((user_tuple.total - user_tuple.active) & user_tuple.experienced), 'inactive_not_experienced': len((user_tuple.total - user_tuple.active) - user_tuple.experienced), 'not_experienced': len(user_tuple.performing - user_tuple.experienced), 'not_performing_not_experienced': len(user_tuple.active - user_tuple.performing - user_tuple.experienced), 'active_ever': len(possible_experience | recently_active), 'possibly_exp': len(possible_experience), 'ever_exp': len(user_tuple.experienced), 'exp_and_active_ever': len(user_tuple.active & user_tuple.experienced), 'active_in_span': len(recently_active), 'eligible_forms': user_tuple.eligible, 'experienced_threshold': domain.internal.experienced_threshold or DEFAULT_EXPERIENCED_THRESHOLD, 'performance_threshold': domain.internal.performance_threshold or DEFAULT_PERFORMANCE_THRESHOLD, } return gir_dict
def country_name_from_isd_code_or_empty(isd_code): cc = COUNTRY_CODE_TO_REGION_CODE.get(isd_code) return force_str(COUNTRIES.get(cc[0])) if cc else ''
def _get_country(domain): project = Domain.get_by_name(domain) if project and project.deployment.countries: return six.text_type(COUNTRIES.get(project.deployment.countries[0], ''))
def country_name_from_isd_code_or_empty(isd_code): cc = COUNTRY_CODE_TO_REGION_CODE.get(isd_code) return force_unicode(COUNTRIES.get(cc[0])) if cc else ''
def _get_country(domain): project = Domain.get_by_name(domain) if project and project.deployment.countries: return unicode(COUNTRIES.get(project.deployment.countries[0], ''))