Files
zulip/zerver/lib/types.py
Yashashvi Dave 621a5cdc35 zerver/models.py: Modify FIELD_TYPE_DATA, add keyword for field type.
This commit modifies FIELD_TYPE_DATA dict in `CustomProfileField`
model to store keyword of field types. And create new dict
FIELD_TYPE_CHOICES_DICT to store all field type information
by field type keyword, i.e. id, name.

This is preparatory commit to remove all static use of field
types in frontend and access field type with keyword instead
of display name.
2018-08-21 11:37:51 -07:00

22 lines
928 B
Python

from typing import TypeVar, Callable, Optional, List, Dict, Union, Tuple, Any
from django.http import HttpResponse
ViewFuncT = TypeVar('ViewFuncT', bound=Callable[..., HttpResponse])
# See zerver/lib/validator.py for more details of Validators,
# including many examples
Validator = Callable[[str, object], Optional[str]]
ExtendedValidator = Callable[[str, str, object], Optional[str]]
RealmUserValidator = Callable[[int, List[int], bool], Optional[str]]
ProfileDataElement = Dict[str, Union[int, float, Optional[str]]]
ProfileData = List[ProfileDataElement]
FieldElement = Tuple[int, str, Validator, Callable[[Any], Any], str]
ExtendedFieldElement = Tuple[int, str, ExtendedValidator, Callable[[Any], Any], str]
UserFieldElement = Tuple[int, str, RealmUserValidator, Callable[[Any], Any], str]
FieldTypeData = List[Union[FieldElement, ExtendedFieldElement, UserFieldElement]]
ProfileFieldData = Dict[str, Dict[str, str]]