Esempio n. 1
0
 def test_all(self):
     """
     It should return all the surveys.
     """
     surveys = Survey.all()
     self.assertEqual(len(surveys), 7)
     self.assertEqual('buildings' in surveys, True)
Esempio n. 2
0
def get_survey_json(survey_file):
    """ Return survey types of campaign in json
    :param survey_file: path of survey to be checked
    :type survey_file: str

    :return: json of survey of type
    :rtype: dict
    """
    return Survey.find_by_name(survey_file).data
Esempio n. 3
0
 def test_init_survey_buildings(self):
     """
     It should initialize a 'buildings' Survey object.
     """
     surveyPath = os.path.join(
         os.path.dirname(__file__),
         '../feature_templates',
         'buildings.yml'
     )
     survey = Survey(surveyPath)
     self.assertEqual(survey.data['feature'], "building=yes")
Esempio n. 4
0
 def test_survey_features(self):
     """
     It should return survey's features.
     """
     surveyPath = os.path.join(
         os.path.dirname(__file__),
         '../feature_templates',
         'buildings.yml'
     )
     survey = Survey.find_by_name(surveyPath)
     self.assertEqual(survey.feature, 'building=yes')
Esempio n. 5
0
class CampaignForm(FlaskForm):
    name = StringField(u'Campaign name',
                       validators=[DataRequired('Campaign name is needed')],
                       description='Name for the campaign',
                       render_kw={'placeholder': 'Campaign name'})
    description = TextAreaField(
        u'Campaign description',
        description='Description for the campaign',
        render_kw={
            'placeholder':
            'Describe the type of features that ' +
            'are being collected and any other participation details.'
        })
    campaign_status = RadioField(u'Campaign status',
                                 description='Status of the campaign',
                                 choices=[('Start', 'Start'),
                                          ('Finish', 'Finish')])
    link_to_omk = BooleanField(u'Add button to integrate OpenMapKit')
    start_date = DateField(u'Start date of campaign',
                           render_kw={
                               'placeholder': 'Start Date',
                               'readonly': 'true'
                           })
    end_date = DateField(u'End date of campaign',
                         render_kw={
                             'placeholder': 'End Date',
                             'readonly': 'true'
                         })
    campaign_managers = ManagerSelectMultipleField(
        u'Managers of campaign',
        validators=[DataRequired('Campaign manager is needed')])
    remote_projects = ManagerSelectMultipleField(u'Remote Projects')
    types_options = SelectField(u'Types of campaign',
                                choices=Survey.to_form(),
                                validators=[Optional()])
    types = HiddenField(u'Types that selected for this campaign')
    uploader = HiddenField(u'Uploader for this campaign')
    geometry = HiddenField(u'Map geometry for this campaign',
                           validators=[DataRequired('Geometry is needed')])
    map_type = StringField(
        u'Campaign Map',
        description='Campaign manager may change the map view',
        validators=[validate_map],
        render_kw={
            'placeholder': 'Add custom basemap tiles URL. ' + 'Use TMS scheme.'
        })
    selected_functions = HiddenField(u'Selected Functions')
    submit = SubmitField(u'Submit')
Esempio n. 6
0
 def test_init_survey_buildings(self):
     """
     It should initialize a 'buildings' Survey object.
     """
     survey = Survey('buildings')
     self.assertEqual(survey.data['tags']['building'], ['yes'])
Esempio n. 7
0
 def test_survey_features(self):
     """
     It should return survey's features.
     """
     survey = Survey.find_by_name('buildings')
     self.assertEqual(survey.feature, 'building')
Esempio n. 8
0
 def test_unknown_survey(self):
     """
     It should return an empty array.
     """
     survey = Survey.find_by_name('unknown')
     self.assertEqual(survey.data, [])
Esempio n. 9
0
def survey_data(survey_name):
    survey = Survey.find_by_name(survey_name)
    return json.dumps(survey.data).replace('True',
                                           'true').replace('False', 'false')