当前位置: 首页>>代码示例>>Python>>正文


Python Poll.register_poll_type方法代码示例

本文整理汇总了Python中poll.models.Poll.register_poll_type方法的典型用法代码示例。如果您正苦于以下问题:Python Poll.register_poll_type方法的具体用法?Python Poll.register_poll_type怎么用?Python Poll.register_poll_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在poll.models.Poll的用法示例。


在下文中一共展示了Poll.register_poll_type方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ValidationError

# 需要导入模块: from poll.models import Poll [as 别名]
# 或者: from poll.models.Poll import register_poll_type [as 别名]
        raise ValidationError(message)
    else:
        return district_value

def parse_location_value(value):
    location_value = find_closest_match(value, Location.objects.exclude(type='district'))
    if not location_value:
        message = _(getattr(settings, 'UNRECOGNIZED_LOCATION_RESPONSE_TEXT', ''))
        raise ValidationError(message)
    else:
        return location_value

Poll.register_poll_type('district', _('District Response'), parse_district_value, db_type=Attribute.TYPE_OBJECT, \
                        view_template='polls/response_location_view.html',
                        edit_template='polls/response_location_edit.html',
                        report_columns=((('Text', 'text', True, 'message__text', SimpleSorter()), (
                            'Location', 'location', True, 'eav_values__generic_value_id', SimpleSorter()), (
                                             'Categories', 'categories', True, 'categories__category__name',
                                             SimpleSorter()))),
                        edit_form=LocationResponseForm)

Poll.register_poll_type('l', _('Location-based'), parse_location_value, db_type=Attribute.TYPE_OBJECT, \
                        view_template='polls/response_location_view.html',
                        edit_template='polls/response_location_edit.html',
                        report_columns=((('Text', 'text', True, 'message__text', SimpleSorter()), (
                            'Location', 'location', True, 'eav_values__generic_value_id', SimpleSorter()), (
                                             'Categories', 'categories', True, 'categories__category__name',
                                             SimpleSorter()))),
                        edit_form=LocationResponseForm)

class PolymorphicManager(models.Manager):
    def get_query_set(self):
开发者ID:unicefuganda,项目名称:rapidsms-uganda-common,代码行数:34,代码来源:models.py

示例2: Numbers

# 需要导入模块: from poll.models import Poll [as 别名]
# 或者: from poll.models.Poll import register_poll_type [as 别名]
XFormField.register_field_type('cvstdelt', 'Time Delta', parse_timedelta,
                               db_type=XFormField.TYPE_INT, xforms_type='integer')

XFormField.register_field_type('cvsmuacr', 'Muac Reading', parse_muacreading,
                               db_type=XFormField.TYPE_TEXT, xforms_type='string')

XFormField.register_field_type('cvsodema', 'Oedema Occurrence', parse_oedema,
                               db_type=XFormField.TYPE_TEXT, xforms_type='string')

XFormField.register_field_type('facility', 'Facility Code', parse_facility,
                               db_type=XFormField.TYPE_OBJECT, xforms_type='string')

XFormField.register_field_type('fuzzynum', 'Fuzzy Numbers (o/0)', parse_fuzzy_number,
                               db_type=XFormField.TYPE_INT, xforms_type='integer')

Poll.register_poll_type('facility', 'Facility Code Response', parse_facility_value, db_type=Attribute.TYPE_OBJECT, view_template='cvs/partials/response_facility_view.html', edit_template='cvs/partials/response_facility_edit.html', report_columns=(('Original Text', 'text'), ('Health Facility', 'custom',),), edit_form='cvs.forms.FacilityResponseForm')

def split_name(patient_name):
    names = patient_name.split(' ')
    first_name = names[0]
    last_name = ''
    middle_name = ''
    if len(names) > 1:
        last_name = names[len(names) - 1]
    if len(names) > 2:
        middle_name = ' '.join(names[1:-1])
    return (first_name, middle_name, last_name)

def get_or_create_patient(health_provider, patient_name, birthdate=None, deathdate=None, gender=None):
    for p in Patient.objects.filter(health_worker=health_provider):
        if dl_distance(p.full_name(), patient_name) <= 1:
开发者ID:unicefuganda,项目名称:rapidsms-cvs,代码行数:33,代码来源:models.py

示例3: select_related

# 需要导入模块: from poll.models import Poll [as 别名]
# 或者: from poll.models.Poll import register_poll_type [as 别名]
            for poll in polls:
                resp_dict[poll.name] = []
                all_responses.extend(
                    poll.responses.exclude(contact__emisreporter__schools=None).filter(date__lte = now).\
                        select_related().values_list('poll__name', 'contact__emisreporter__schools__pk', 'date'))

        # populate the res_dict with school_pk and sent_at values as a list of lists
        for poll_name, school_pk, sent_at in all_responses:
            resp_dict[poll_name].append([school_pk, sent_at])

        for poll_name in resp_dict.keys():
            try:
                poll = Poll.objects.get(name = poll_name)
                other_responses = resp_dict[poll_name]
                for school_pk, sent_at in other_responses:
                    school = School.objects.select_related().get(pk = school_pk)
                    model.objects.create(
                        poll = poll,
                        school = school,
                        sent_at = sent_at)
            except ObjectDoesNotExist:
                pass
            return

Poll.register_poll_type('date', 'Date Response', parse_date_value, db_type=Attribute.TYPE_OBJECT)

script_progress_was_completed.connect(edtrac_autoreg, weak=False)
script_progress_was_completed.connect(edtrac_reschedule_script, weak=False)
script_progress.connect(edtrac_autoreg_transition, weak=False)
script_progress.connect(edtrac_attendance_script_transition, weak=False)
开发者ID:krelamparo,项目名称:edtrac,代码行数:32,代码来源:utils.py

示例4: return

# 需要导入模块: from poll.models import Poll [as 别名]
# 或者: from poll.models.Poll import register_poll_type [as 别名]
        try:
            return (now - datetime.datetime.strptime(lvalue, '%m/%d/%Y')).days
        except ValueError:
            rx = re.compile('[0-9]*')
            m = rx.match(lvalue)
            number = lvalue[m.start():m.end()].strip()
            unit = lvalue[m.end():].strip()
            if number:
                number = int(number)
                unit_amounts = {
                    'd':1,
                    'w':7,
                    'm':30,
                    'y':365,
                }
                unit_dict = {
                    'd':('day', 'days', 'dys', 'ds'),
                    'w':('wk', 'wks', 'weeks', 'week'),
                    'm':('mo', 'months', 'month', 'mnths', 'mos', 'ms', 'mns', 'mnth'),
                    'y':('year', 'years', 'yr', 'yrs'),
                }
                for key, words in unit_dict.iteritems():
                    if unit == key:
                        return number * unit_amounts[key]
                    for word in words:
                        if dl_distance(word, unit) <= 1:
                            return number * unit_amounts[key]
        # raise ValidationError

Poll.register_poll_type('timedelt', 'Time Length', parse_timedelta, db_type=Attribute.TYPE_FLOAT)
开发者ID:revence27,项目名称:mother,代码行数:32,代码来源:models.py


注:本文中的poll.models.Poll.register_poll_type方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。