# Path: memopol/search/forms.py
# class MEPSearchForm(HaystackForm):
#     options_form_class = MEPSearchOptionsForm
# 
#     FILTER_NAME = FILTER_NAME
# 
#     _FILTERS_BY_FIELD = {
#         FILTER_NAME.FULLTEXT: {
#             'type': 'fulltext',
#             'receptacle': 'fulltext'
#         },
#         FILTER_NAME.IS_ACTIVE: {
#             'type': 'yes_no',
#             'receptacle': 'yes_no',
#         },
#         FILTER_NAME.COUNTRY: {
#             'type': 'str',
#             'receptacle': 'country',
#         },
#         FILTER_NAME.GROUP: {
#             'type': 'str',
#             'receptacle': 'group',
#         },
#         FILTER_NAME.COMMITTEE: {
#             'type': 'str',
#             'receptacle': 'committees',
#         },
#         FILTER_NAME.DELEGATION: {
#             'type': 'id',
#             'receptacle': 'delegations',
#         },
#         FILTER_NAME.TOTAL_SCORE: {
#             'type': 'int',
#             'receptacle': 'int',
#         },
#         FILTER_NAME.ACHIEVEMENT: {
#             'type': 'id',
#             'receptacle': 'autocomplete',
#             'autocomplete_lookup': 'mep_achievements',
#         },
#         FILTER_NAME.BXL_BUILDING: {
#             'type': 'str',
#             'receptacle': 'bxl_building',
#         },
#         FILTER_NAME.BXL_FLOOR: {
#             'type': 'str',
#             'receptacle': 'str',
#         },
#         FILTER_NAME.STG_BUILDING: {
#             'type': 'str',
#             'receptacle': 'stg_building',
#         },
#         FILTER_NAME.STG_FLOOR: {
#             'type': 'str',
#             'receptacle': 'str',
#         },
#     }
# 
#     filter_value_country = StrChoiceField(COUNTRY)
#     filter_value_group = StrChoiceField(GROUP)
#     filter_value_committees = StrChoiceField(COMMITTEE)
#     filter_value_delegations = IntChoiceField(DELEGATION)
#     filter_value_bxl_building = StrChoiceField(BXL_BUILDING)
#     filter_value_stg_building = StrChoiceField(STG_BUILDING)
# 
#     JS_FILTERS_BUILDERS = (
#         (u'reset', {
#             'replace': True,
#             'filter_name': FILTER_NAME.FULLTEXT
#         }),
#         (u'active', {
#             'filter_name': FILTER_NAME.IS_ACTIVE,
#             'filter_lookup': HaystackForm.FILTER_LOOKUPS_INT.EXACT,
#             'filter_value': YES_NO.YES,
#         }),
#         (u'name', {
#             'filter_name': FILTER_NAME.FULLTEXT,
#             'previous_right_op': HaystackForm.FILTER_RIGHT_OP.AND,
#         }),
#     )
# 
# class MEPSearchOptionsForm(SearchOptionsForm):
# 
#     SORT = SORT_CHOICES
#     SORT_INITIAL = SORT.LAST_NAME
#     LIMIT_INITIAL = 30
# 
#     as_csv = forms.BooleanField(
#                 required=False,
#                 initial=False,
#                 label=_("Download as CSV"),
#             )
# 
#     limit = forms.IntegerField(
#                 min_value=0,
#                 max_value=100,
#                 required=True,
#                 initial=30,
#                 label=_("Total results")
#             )


from dynamiq.shortcuts import SearchShortcut
from .forms import MEPSearchForm, MEPSearchOptionsForm

class MEPBaseShortcut(SearchShortcut):
    base_url_name = "search"


class TopRated(MEPBaseShortcut):
    title = u"Top rated"

    def __init__(self, request):
        super(TopRated, self).__init__(request)
        self.options = {
            'sort': MEPSearchOptionsForm.SORT.TOTAL_SCORE,
            'limit': 15,
        }
        self.filters = [
            {
                'filter_name': 'total_score',
                'int_lookup': MEPSearchForm.FILTER_LOOKUPS_INT.GTE,
                'filter_value_int': 50,
                'filter_right_op': MEPSearchForm.FILTER_RIGHT_OP.EMPTY
            },
        ]


class WorstRated(MEPBaseShortcut):
    title = u"Worst rated"

    def __init__(self, request):
        super(WorstRated, self).__init__(request)
        self.options = {

# Path: memopol/search/forms.py
# class MEPSearchForm(HaystackForm):
#     options_form_class = MEPSearchOptionsForm
# 
#     FILTER_NAME = FILTER_NAME
# 
#     _FILTERS_BY_FIELD = {
#         FILTER_NAME.FULLTEXT: {
#             'type': 'fulltext',
#             'receptacle': 'fulltext'
#         },
#         FILTER_NAME.IS_ACTIVE: {
#             'type': 'yes_no',
#             'receptacle': 'yes_no',
#         },
#         FILTER_NAME.COUNTRY: {
#             'type': 'str',
#             'receptacle': 'country',
#         },
#         FILTER_NAME.GROUP: {
#             'type': 'str',
#             'receptacle': 'group',
#         },
#         FILTER_NAME.COMMITTEE: {
#             'type': 'str',
#             'receptacle': 'committees',
#         },
#         FILTER_NAME.DELEGATION: {
#             'type': 'id',
#             'receptacle': 'delegations',
#         },
#         FILTER_NAME.TOTAL_SCORE: {
#             'type': 'int',
#             'receptacle': 'int',
#         },
#         FILTER_NAME.ACHIEVEMENT: {
#             'type': 'id',
#             'receptacle': 'autocomplete',
#             'autocomplete_lookup': 'mep_achievements',
#         },
#         FILTER_NAME.BXL_BUILDING: {
#             'type': 'str',
#             'receptacle': 'bxl_building',
#         },
#         FILTER_NAME.BXL_FLOOR: {
#             'type': 'str',
#             'receptacle': 'str',
#         },
#         FILTER_NAME.STG_BUILDING: {
#             'type': 'str',
#             'receptacle': 'stg_building',
#         },
#         FILTER_NAME.STG_FLOOR: {
#             'type': 'str',
#             'receptacle': 'str',
#         },
#     }
# 
#     filter_value_country = StrChoiceField(COUNTRY)
#     filter_value_group = StrChoiceField(GROUP)
#     filter_value_committees = StrChoiceField(COMMITTEE)
#     filter_value_delegations = IntChoiceField(DELEGATION)
#     filter_value_bxl_building = StrChoiceField(BXL_BUILDING)
#     filter_value_stg_building = StrChoiceField(STG_BUILDING)
# 
#     JS_FILTERS_BUILDERS = (
#         (u'reset', {
#             'replace': True,
#             'filter_name': FILTER_NAME.FULLTEXT
#         }),
#         (u'active', {
#             'filter_name': FILTER_NAME.IS_ACTIVE,
#             'filter_lookup': HaystackForm.FILTER_LOOKUPS_INT.EXACT,
#             'filter_value': YES_NO.YES,
#         }),
#         (u'name', {
#             'filter_name': FILTER_NAME.FULLTEXT,
#             'previous_right_op': HaystackForm.FILTER_RIGHT_OP.AND,
#         }),
#     )
# 
# class MEPSearchOptionsForm(SearchOptionsForm):
# 
#     SORT = SORT_CHOICES
#     SORT_INITIAL = SORT.LAST_NAME
#     LIMIT_INITIAL = 30
# 
#     as_csv = forms.BooleanField(
#                 required=False,
#                 initial=False,
#                 label=_("Download as CSV"),
#             )
# 
#     limit = forms.IntegerField(
#                 min_value=0,
#                 max_value=100,
#                 required=True,
#                 initial=30,
#                 label=_("Total results")
#             )


# Path: memopol/search/shortcuts.py
from dynamiq.shortcuts import SearchShortcut
from .forms import MEPSearchForm, MEPSearchOptionsForm


class MEPBaseShortcut(SearchShortcut):
    base_url_name = "search"


class TopRated(MEPBaseShortcut):
    title = u"Top rated"

    def __init__(self, request):
        super(TopRated, self).__init__(request)
        self.options = {
            'sort': MEPSearchOptionsForm.SORT.TOTAL_SCORE,
            'limit': 15,
        }
        self.filters = [
            {
                'filter_name': 'total_score',
                'int_lookup': MEPSearchForm.FILTER_LOOKUPS_INT.GTE,
                'filter_value_int': 50,
                'filter_right_op': MEPSearchForm.FILTER_RIGHT_OP.EMPTY
            },
        ]


class WorstRated(MEPBaseShortcut):
    title = u"Worst rated"

    def __init__(self, request):
        super(WorstRated, self).__init__(request)
        self.options = {

            'sort': MEPSearchOptionsForm.SORT.TOTAL_SCORE_ASC,