<s> import pytz <EOL> from django . utils . translation import ugettext as _ <EOL> from corehq . apps . reports . filters . base import BaseSingleOptionFilter <EOL> from custom . fri . models import PROFILE_A , PROFILE_B , PROFILE_C , PROFILE_D , PROFILE_E , PROFILE_F , PROFILE_G , PROFILE_H , PROFILE_DESC <EOL> from custom . fri . api import get_interactive_participants <EOL> from datetime import datetime , date , timedelta <EOL> from dimagi . utils . parsing import json_format_date <EOL> class InteractiveParticipantFilter ( BaseSingleOptionFilter ) : <EOL> slug = "<STR_LIT>" <EOL> label = _ ( "<STR_LIT>" ) <EOL> @ property <EOL> def options ( self ) : <EOL> cases = get_interactive_participants ( self . domain ) <EOL> return [ ( case . get_id , case . name ) for case in cases ] <EOL> class RiskProfileFilter ( BaseSingleOptionFilter ) : <EOL> slug = "<STR_LIT>" <EOL> label = _ ( "<STR_LIT>" ) <EOL> default_text = _ ( "<STR_LIT>" ) <EOL> @ property <EOL> def options ( self ) : <EOL> return [ <EOL> ( PROFILE_A , PROFILE_DESC [ PROFILE_A ] ) , <EOL> ( PROFILE_B , PROFILE_DESC [ PROFILE_B ] ) , <EOL> ( PROFILE_C , PROFILE_DESC [ PROFILE_C ] ) , <EOL> ( PROFILE_D , PROFILE_DESC [ PROFILE_D ] ) , <EOL> ( PROFILE_E , PROFILE_DESC [ PROFILE_E ] ) , <EOL> ( PROFILE_F , PROFILE_DESC [ PROFILE_F ] ) , <EOL> ( PROFILE_G , PROFILE_DESC [ PROFILE_G ] ) , <EOL> ( PROFILE_H , PROFILE_DESC [ PROFILE_H ] ) , <EOL> ] <EOL> class SurveyDateSelector ( BaseSingleOptionFilter ) : <EOL> """<STR_LIT>""" <EOL> slug = "<STR_LIT>" <EOL> label = _ ( "<STR_LIT>" ) <EOL> default_text = _ ( "<STR_LIT>" ) <EOL> @ classmethod <EOL> def get_value ( cls , * args , ** kwargs ) : <EOL> default = json_format_date ( cls . get_date_choices ( ) [ - <NUM_LIT:1> ] ) <EOL> return super ( SurveyDateSelector , cls ) . get_value ( * args , ** kwargs ) or default <EOL> @ classmethod <EOL> def get_date_choices ( cls ) : <EOL> next_date = date ( <NUM_LIT> , <NUM_LIT:3> , <NUM_LIT> ) <EOL> last_date = pytz . utc . localize ( datetime . utcnow ( ) ) <EOL> last_date = last_date . astimezone ( pytz . timezone ( "<STR_LIT>" ) ) <EOL> last_date = last_date . date ( ) <EOL> dates = [ ] <EOL> while next_date <= last_date : <EOL> dates . append ( next_date ) <EOL> next_date += timedelta ( days = <NUM_LIT:7> ) <EOL> return dates <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> super ( SurveyDateSelector , self ) . __init__ ( * args , ** kwargs ) <EOL> self . _date_choices = SurveyDateSelector . get_date_choices ( ) <EOL> @ property <EOL> def options ( self ) : <EOL> result = [ ] <EOL> for date in sorted ( self . _date_choices , reverse = True ) : <EOL> result . append ( ( json_format_date ( date ) , date . strftime ( "<STR_LIT>" ) ) ) <EOL> return result </s>
