Example #1
0
    def __init__(self, request, filters):
        """Initialize the ballot box form data
        
        filters are a list of type filter         
        """
        self.filters = filters

        for x in request.values.keys():
            form_filter = helpers.get_first([f for f in self.filters if f.name == x])
            if form_filter:
                form_filter.value = request.values[x]

        self.contest_id = request.values.get('contest_id', '')

        self.search = request.values.get('search', '')

        self.contests = []
        self.all_opinions = []
        self.official_opinions = []
        self.all_opinion_summary = []
        self.official_opinion_summary = []
        self.contest = None
        self.contest_groups = []

        self.search_results = request.values.get('search_results', '')
Example #2
0
 def test_get_first(self):
     self.assertEqual(helpers.get_first([1, 2]), 1)
     self.assertEqual(helpers.get_first([], 1), 1)
     self.assertEqual(helpers.get_first(None, 1), 1)
Example #3
0
 def test_get_first(self):
     self.assertEqual(helpers.get_first([1, 2]), 1)
     self.assertEqual(helpers.get_first([], 1), 1)
     self.assertEqual(helpers.get_first(None, 1), 1)