def populate_db_tags(): """Populate the database Tag model""" tags = [ Tag('all'), Tag('dli'), Tag('morning'), ] db.session.add_all(tags) db.session.commit()
def validate(self): """Validate the form""" if not Form.validate(self): return False self.chart = Chart.query.get(self.chart_id.data) chart_fields = Field.query.filter(Field.id.in_([int(f) for f in self.fields.data if f])).all() tags = [ Tag.get_or_create(tag.strip()) for tag in self.tags.data if tag.strip() ] res = True ctype = ChartType.query.get(self.chart_type.data) if not ctype: self.chart_type.errors.append("Chart Type not found!") res = False self.chart.name = self.name.data self.chart.with_table = self.with_table.data self.chart.ctype = ctype self.chart.fields = chart_fields self.chart.tags = tags return res
def validate(self): """Validate the form""" res = True if not Form.validate(self): res = False report_fields = Field.query.filter(Field.id.in_([int(f) for f in self.fields.data if f])).all() tags = [ Tag.get_or_create(tag.strip()) for tag in self.tags.data if tag.strip() ] user = User.query.get(self.user_id.data) if not user: self.user_id.errors.append("User not found!") res = False self.report = Report( user=user, name=self.name.data, fields=report_fields, tags=tags, ) return res
def validate(self): """Validate the form""" if not Form.validate(self): return False self.chart = Chart.query.get(self.chart_id.data) chart_fields = Field.query.filter( Field.id.in_([int(f) for f in self.fields.data if f])).all() tags = [ Tag.get_or_create(tag.strip()) for tag in self.tags.data if tag.strip() ] res = True ctype = ChartType.query.get(self.chart_type.data) if not ctype: self.chart_type.errors.append("Chart Type not found!") res = False self.chart.name = self.name.data self.chart.with_table = self.with_table.data self.chart.ctype = ctype self.chart.fields = chart_fields self.chart.tags = tags return res
def validate(self): """Validate the form""" res = True if not Form.validate(self): res = False report_fields = Field.query.filter( Field.id.in_([int(f) for f in self.fields.data if f])).all() tags = [ Tag.get_or_create(tag.strip()) for tag in self.tags.data if tag.strip() ] user = User.query.get(self.user_id.data) if not user: self.user_id.errors.append("User not found!") res = False self.report = Report( user=user, name=self.name.data, fields=report_fields, tags=tags, ) return res
def validate(self): """Validate the form""" if not Form.validate(self): return False self.report = Report.query.get(self.report_id.data) report_fields = Field.query.filter(Field.id.in_([int(f) for f in self.fields.data if f])).all() tags = [ Tag.get_or_create(tag.strip()) for tag in self.tags.data if tag.strip() ] self.report.name = self.name.data self.report.fields = report_fields self.report.tags = tags return True
def validate(self): """Validate the form""" res = True if not Form.validate(self): res = False chart_fields = Field.query.filter( Field.id.in_([int(f) for f in self.fields.data if f])).all() tags = [ Tag.get_or_create(tag.strip()) for tag in self.tags.data if tag.strip() ] user = User.query.get(self.user_id.data) if not user: self.user_id.errors.append("User not found!") res = False ctype = ChartType.query.get(self.chart_type.data) if not ctype: self.chart_type.errors.append("Chart Type not found!") res = False if not len(chart_fields): self.with_table.errors.append( "You've created an empty chart!") res = False if not self.with_table.data and ctype == ChartTypeConstants.TABLE_ONLY: # It's a fair assumption that the user actually wanted a table self.with_table.data = True self.chart = Chart( name=self.name.data, with_table=self.with_table.data, user=user, ctype=ctype, fields=chart_fields, tags=tags, ) return res
def validate(self): """Validate the form""" if not Form.validate(self): return False self.report = Report.query.get(self.report_id.data) report_fields = Field.query.filter( Field.id.in_([int(f) for f in self.fields.data if f])).all() tags = [ Tag.get_or_create(tag.strip()) for tag in self.tags.data if tag.strip() ] self.report.name = self.name.data self.report.fields = report_fields self.report.tags = tags return True
def validate(self): """Validate the form""" res = True if not Form.validate(self): res = False chart_fields = Field.query.filter(Field.id.in_([int(f) for f in self.fields.data if f])).all() tags = [ Tag.get_or_create(tag.strip()) for tag in self.tags.data if tag.strip() ] user = User.query.get(self.user_id.data) if not user: self.user_id.errors.append("User not found!") res = False ctype = ChartType.query.get(self.chart_type.data) if not ctype: self.chart_type.errors.append("Chart Type not found!") res = False if not len(chart_fields): self.with_table.errors.append("You've created an empty chart!") res = False if not self.with_table.data and ctype == ChartTypeConstants.TABLE_ONLY: # It's a fair assumption that the user actually wanted a table self.with_table.data = True self.chart = Chart( name=self.name.data, with_table=self.with_table.data, user=user, ctype=ctype, fields=chart_fields, tags=tags, ) return res