class FiltersetForm(forms.Form): title = forms.StringField(__("Title"), description=__("A title shown to viewers"), validators=[forms.validators.DataRequired()], filters=[forms.filters.strip()]) description = forms.TinyMce4Field( __("Description"), content_css=content_css, description=__("Description shown to viewers and search engines"), validators=[forms.validators.DataRequired()]) types = QuerySelectMultipleField(__("Job types"), widget=ListWidget(), option_widget=CheckboxInput(), get_label='title', validators=[forms.validators.Optional()]) categories = QuerySelectMultipleField( __("Job categories"), widget=ListWidget(), option_widget=CheckboxInput(), get_label='title', validators=[forms.validators.Optional()]) geonameids = forms.GeonameSelectMultiField("Locations", filters=[format_geonameids]) remote_location = forms.BooleanField(__("Match remote jobs")) pay_cash_currency = forms.RadioField( __("Currency"), choices=get_currency_choices(), default='', validators=[forms.validators.Optional()]) pay_cash = forms.IntegerField(__("Pay"), description=__("Minimum pay"), validators=[forms.validators.Optional()]) keywords = forms.StringField(__("Keywords"), validators=[forms.validators.Optional()], filters=[forms.filters.strip()]) auto_domains = forms.AutocompleteMultipleField( __("Domains"), autocomplete_endpoint='/api/1/domain/autocomplete', results_key='domains') auto_tags = forms.AutocompleteMultipleField( __("Tags"), autocomplete_endpoint='/api/1/tag/autocomplete', results_key='tags') def set_queries(self): if not self.edit_parent: self.edit_parent = g.board self.types.query = JobType.query.join(board_jobtype_table).filter( board_jobtype_table.c.board_id == self.edit_parent.id).order_by( 'title') self.categories.query = JobCategory.query.join( board_jobcategory_table).filter( board_jobcategory_table.c.board_id == self.edit_parent.id).order_by('title')
class BoardTaggingForm(forms.Form): auto_domains = forms.TextListField(__("Email Domains"), description=__("Jobs from any of these email domains will be automatically added to this board. " "One per line. Do NOT add the www prefix")) auto_geonameids = forms.GeonameSelectMultiField(__("Locations"), description=__("Jobs in any of these locations will be automatically added to this board")) auto_keywords = forms.AutocompleteMultipleField(__("Tags"), autocomplete_endpoint='/api/1/tag/autocomplete', results_key='tags', description=__("Jobs tagged with these keywords will be automatically added to this board")) auto_types = QuerySelectMultipleField(__("Job types"), query_factory=lambda: JobType.query.filter_by(private=False).order_by(JobType.seq), get_label='title', description=__(u"Jobs of this type will be automatically added to this board")) auto_categories = QuerySelectMultipleField(__("Job categories"), query_factory=lambda: JobCategory.query.filter_by(private=False).order_by(JobCategory.seq), get_label='title', description=__(u"Jobs of this category will be automatically added to this board")) auto_all = forms.BooleanField(__("All of the above criteria must match"), description=__(u"Select this if, for example, you want to match all programming jobs in Bangalore " u"and not all programming jobs or Bangalore-based jobs.")) def validate_auto_domains(self, field): relist = [] for item in field.data: item = item.strip() if u',' in item: relist.extend([x.strip() for x in item.split(',')]) elif u' ' in item: relist.extend([x.strip() for x in item.split(' ')]) else: relist.append(item) domains = set() for item in relist: if item: # FIXME: This will break domains where the subdomain handles email r = tldextract.extract(item.lower()) d = u'.'.join([r.domain, r.suffix]) if not is_public_email_domain(d, default=False): domains.add(d) field.data = list(domains) def validate_auto_geonameids(self, field): field.data = [int(x) for x in field.data if x.isdigit()]