"""
.. module:: report.forms.

    :synopsis: Defines forms used for report statistics.
"""
from flask_wtf import Form
from wtforms import SelectField
from flask_login import current_user

from app.lib.db_utils import get_agency_choices


class ReportFilterForm(Form):
    """
    Form for users to filter different report statistics.

    agency: agency selected to filter by
    user: active agency user selected to filter by
    """
    agency = SelectField('Agency Filter', choices=None)
    user = SelectField('Agency User Filter', choices=None)

    def __init__(self):
        super(ReportFilterForm, self).__init__()
        self.agency.choices = get_agency_choices()
        self.agency.choices.insert(0, ('all', 'All'))
        self.user.choices = []
        user_agencies = sorted([(agencies.ein, agencies.name)
                                for agencies in current_user.agencies],
                               key=lambda x: x[1])
        for user_agency in user_agencies:
            self.agency.choices.insert(1, self.agency.choices.pop(self.agency.choices.index(user_agency)))

@@ -754,16 +754,55 @@
 es = %5B%5D%0A
+        if current_user.is_agency:%0A    
         
@@ -883,24 +883,28 @@
             
+   
+ 
 for agencies
@@ -962,16 +962,20 @@
         
+    
 key=lamb
@@ -990,24 +990,28 @@
 1%5D)%0A        
+  
+  
 for user_age
@@ -1032,16 +1032,20 @@
 encies:%0A
+    
         

fix to reports not showing for non-agency users