Skip to content

Commit

Permalink
Merge pull request #59 from GSA/lint-fixes
Browse files Browse the repository at this point in the history
lints all files
  • Loading branch information
rshewitt authored Apr 29, 2024
2 parents 8f52c3e + b99b2d0 commit f695fd5
Show file tree
Hide file tree
Showing 19 changed files with 427 additions and 331 deletions.
26 changes: 15 additions & 11 deletions app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
from flask import Flask
from .models import db
from flask_migrate import Migrate
import os

from dotenv import load_dotenv
from flask import Flask
from flask_bootstrap import Bootstrap
from flask_migrate import Migrate

from .models import db

load_dotenv()

DATABASE_URI = os.getenv('DATABASE_URI')
DATABASE_URI = os.getenv("DATABASE_URI")


def create_app(testing=False):
app = Flask(__name__)

if testing:
app.config['TESTING'] = True
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///:memory:'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.config["TESTING"] = True
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///:memory:"
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
else:
app.config['SQLALCHEMY_DATABASE_URI'] = os.getenv("DATABASE_URI")
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.config['SECRET_KEY'] = os.urandom(16)
app.config["SQLALCHEMY_DATABASE_URI"] = os.getenv("DATABASE_URI")
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
app.config["SECRET_KEY"] = os.urandom(16)
Bootstrap(app)

db.init_app(app)
Expand All @@ -28,6 +31,7 @@ def create_app(testing=False):
Migrate(app, db)

from .routes import register_routes

register_routes(app)

return app
return app
61 changes: 35 additions & 26 deletions app/forms.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,44 @@
from flask_wtf import FlaskForm
from wtforms import StringField, SubmitField, SelectField, TextAreaField
from wtforms.validators import DataRequired, URL, ValidationError
import re

from flask_wtf import FlaskForm
from wtforms import SelectField, StringField, SubmitField, TextAreaField
from wtforms.validators import URL, DataRequired, ValidationError


def validate_email_list(form, field):
emails = field.data.split(',')
emails = field.data.split(",")
for email in emails:
if not re.match(r"[^@]+@[^@]+\.[^@]+", email.strip()):
raise ValidationError("Invalid email address: {}".format(email))



class HarvestSourceForm(FlaskForm):
organization_id = SelectField('Organization',
choices=[], validators=[DataRequired()])
name = StringField('Name', validators=[DataRequired()])
url = StringField('URL', validators=[DataRequired(), URL()])
emails = TextAreaField('Notification_emails',
validators=[DataRequired(), validate_email_list])
frequency = SelectField('Frequency',
choices=['Manual', 'Daily', 'Weekly', 'Biweekly','Monthly'],
validators=[DataRequired()])
user_requested_frequency = StringField('User_requested_frequency',
validators=[DataRequired()])
schema_type = SelectField('Schema Type',
choices=['strict', 'other'],
validators=[DataRequired()])
source_type = SelectField('Source Type',
choices=['Datajson', 'WAF'],
validators=[DataRequired()])
submit = SubmitField('Submit')
organization_id = SelectField(
"Organization", choices=[], validators=[DataRequired()]
)
name = StringField("Name", validators=[DataRequired()])
url = StringField("URL", validators=[DataRequired(), URL()])
emails = TextAreaField(
"Notification_emails", validators=[DataRequired(), validate_email_list]
)
frequency = SelectField(
"Frequency",
choices=["Manual", "Daily", "Weekly", "Biweekly", "Monthly"],
validators=[DataRequired()],
)
user_requested_frequency = StringField(
"User_requested_frequency", validators=[DataRequired()]
)
schema_type = SelectField(
"Schema Type", choices=["strict", "other"], validators=[DataRequired()]
)
source_type = SelectField(
"Source Type", choices=["Datajson", "WAF"], validators=[DataRequired()]
)
submit = SubmitField("Submit")


class OrganizationForm(FlaskForm):
name = StringField('Name', validators=[DataRequired()])
logo = StringField('Logo', validators=[DataRequired()])
submit = SubmitField('Submit')
name = StringField("Name", validators=[DataRequired()])
logo = StringField("Logo", validators=[DataRequired()])
submit = SubmitField("Submit")
Loading

1 comment on commit f695fd5

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
harvester
   __init__.py50100% 
   ckan_utils.py4222 95%
   exceptions.py420100% 
   harvest.py4256565 85%
   logger_config.py10100% 
   utils.py6299 85%
TOTAL5777687% 

Tests Skipped Failures Errors Time
35 0 💤 0 ❌ 0 🔥 4.189s ⏱️

Please sign in to comment.