Skip to content

Commit

Permalink
Merge pull request #515 from CityOfNewYork/develop
Browse files Browse the repository at this point in the history
OpenRecords v3.4.0
  • Loading branch information
joelbcastillo authored Aug 23, 2019
2 parents 4313ec7 + e06c527 commit aed2a55
Show file tree
Hide file tree
Showing 28 changed files with 1,846 additions and 1,558 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ APP_VERSION_STRING=<STRING OF APP VERSION>
LOGFILE_DIRECTORY=<PATH TO LOG DIRECTORY>

# Data
APP_LAUNCH_DATE=<DATE OF LAUNCH (%Y-%m-%d)>
AGENCY_DATA=<FULL PATH TO "agencies.json">
CUSTOM_REQUEST_FORMS=<FULL PATH TO "custom_request_forms.json">
LETTER_TEMPLATES_DATA=<FULL PATH TO "letter_templates.csv">
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,6 @@ data/FOIL-*
data_test/*
executables/*
openrecords.code-workspace
celerybeat-schedule
*.pid
*.pgdump
Empty file modified .startup/fakesmtp_startup.sh
100644 → 100755
Empty file.
Empty file modified .startup/flask_startup.sh
100644 → 100755
Empty file.
Empty file modified .startup/tmux_setup.sh
100644 → 100755
Empty file.
3 changes: 1 addition & 2 deletions app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@
email_redis = redis.StrictRedis(
db=Config.EMAIL_REDIS_DB, host=Config.REDIS_HOST, port=Config.REDIS_PORT)

holidays = NYCHolidays(years=[year for year in range(
date.today().year, date.today().year + 5)])
holidays = NYCHolidays(years=[year for year in range(Config.APP_LAUNCH_DATE.year, date.today().year + 5)])
calendar = Calendar(
workdays=[MO, TU, WE, TH, FR],
holidays=[str(key) for key in holidays.keys()]
Expand Down
154 changes: 82 additions & 72 deletions app/auth/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,8 @@
"""

from flask_wtf import Form
from wtforms import (
StringField,
SelectField,
PasswordField,
SubmitField,
)
from wtforms.validators import (
Length,
Email,
Optional,
DataRequired
)
from wtforms import StringField, SelectField, PasswordField, SubmitField
from wtforms.validators import Length, Email, Optional, DataRequired

from app.constants import STATES
from app.models import Agencies
Expand All @@ -31,13 +21,13 @@ class StripFieldsForm(Form):

class Meta:
def bind_field(self, form, unbound_field, options):
filters = unbound_field.kwargs.get('filters', [])
filters = unbound_field.kwargs.get("filters", [])
filters.append(strip_filter)
return unbound_field.bind(form=form, filters=filters, **options)


def strip_filter(value):
if value is not None and hasattr(value, 'strip'):
if value is not None and hasattr(value, "strip"):
return value.strip()
return value

Expand All @@ -53,18 +43,25 @@ class ManageUserAccountForm(StripFieldsForm):
Mailing Address: The user's mailing address; Optional;
Format: Address One, Address Two, City, State, Zip (5 Digits)
"""
title = StringField('Title', validators=[Length(max=64), Optional()])
organization = StringField('Organization', validators=[Length(max=254), Optional()])
notification_email = StringField('Notification Email', validators=[Email(), Length(max=254), Optional()])
phone_number = StringField('Phone', validators=[Length(min=10, max=25), Optional()])
fax_number = StringField('Fax', validators=[Length(min=10, max=25), Optional()])
address_one = StringField('Line 1', validators=[Optional()])
address_two = StringField('Line 2', validators=[Optional()])
city = StringField('City', validators=[Optional()])
state = SelectField('State', choices=STATES, default='NY', validators=[Optional()])
zipcode = StringField('Zip Code (5 Digits)', validators=[Length(min=5, max=5), Optional()])

submit = SubmitField('Update OpenRecords Account')

title = StringField("Title", validators=[Length(max=64), Optional()])
organization = StringField("Organization", validators=[Length(max=254), Optional()])
notification_email = StringField(
"Notification Email", validators=[Email(), Length(max=254), Optional()]
)
phone_number = StringField("Phone", validators=[Length(min=10, max=25), Optional()])
fax_number = StringField("Fax", validators=[Length(min=10, max=25), Optional()])
address_one = StringField("Line 1", validators=[Optional()])
address_two = StringField("Line 2", validators=[Optional()])
city = StringField("City", validators=[Optional()])
state = SelectField(
"State / U.S. Territory", choices=STATES, default="NY", validators=[Optional()]
)
zipcode = StringField(
"Zip Code (5 Digits)", validators=[Length(min=5, max=5), Optional()]
)

submit = SubmitField("Update OpenRecords Account")

def __init__(self, user=None):
"""
Expand All @@ -77,29 +74,32 @@ def autofill(self):
if self.user is not None:
self.title.data = self.user.title
self.organization.data = self.user.organization
self.notification_email.data = self.user.notification_email or self.user.email
self.notification_email.data = (
self.user.notification_email or self.user.email
)
self.phone_number.data = self.user.phone_number
self.fax_number.data = self.user.fax_number
if self.user.mailing_address is not None:
self.address_one.data = self.user.mailing_address.get('address_one')
self.address_two.data = self.user.mailing_address.get('address_two')
self.city.data = self.user.mailing_address.get('city')
self.state.data = self.user.mailing_address.get('state')
self.zipcode.data = self.user.mailing_address.get('zip')
self.address_one.data = self.user.mailing_address.get("address_one")
self.address_two.data = self.user.mailing_address.get("address_two")
self.city.data = self.user.mailing_address.get("city")
self.state.data = self.user.mailing_address.get("state")
self.zipcode.data = self.user.mailing_address.get("zip")

def validate(self):
""" One mthod of contact must be provided. """
base_is_valid = super(ManageUserAccountForm, self).validate()
return base_is_valid and bool(
self.notification_email.data or
self.phone_number.data or
self.fax_number.data or
( # mailing address
self.address_one.data and
self.city.data and
self.state.data and
self.zipcode.data
))
self.notification_email.data
or self.phone_number.data
or self.fax_number.data
or ( # mailing address
self.address_one.data
and self.city.data
and self.state.data
and self.zipcode.data
)
)


class ManageAgencyUserAccountForm(StripFieldsForm):
Expand All @@ -113,19 +113,26 @@ class ManageAgencyUserAccountForm(StripFieldsForm):
Mailing Address: The user's mailing address; Optional;
Format: Address One, Address Two, City, State, Zip (5 Digits)
"""
default_agency = SelectField('Primary Agency', validators=[DataRequired()])
title = StringField('Title', validators=[Length(max=64), Optional()])
organization = StringField('Organization', validators=[Length(max=254), Optional()])
notification_email = StringField('Notification Email', validators=[Email(), Length(max=254), Optional()])
phone_number = StringField('Phone', validators=[Length(min=10, max=25), Optional()])
fax_number = StringField('Fax', validators=[Length(min=10, max=25), Optional()])
address_one = StringField('Line 1', validators=[Optional()])
address_two = StringField('Line 2', validators=[Optional()])
city = StringField('City', validators=[Optional()])
state = SelectField('State', choices=STATES, default='NY', validators=[Optional()])
zipcode = StringField('Zip Code (5 Digits)', validators=[Length(min=5, max=5), Optional()])

submit = SubmitField('Update OpenRecords Account')

default_agency = SelectField("Primary Agency", validators=[DataRequired()])
title = StringField("Title", validators=[Length(max=64), Optional()])
organization = StringField("Organization", validators=[Length(max=254), Optional()])
notification_email = StringField(
"Notification Email", validators=[Email(), Length(max=254), Optional()]
)
phone_number = StringField("Phone", validators=[Length(min=10, max=25), Optional()])
fax_number = StringField("Fax", validators=[Length(min=10, max=25), Optional()])
address_one = StringField("Line 1", validators=[Optional()])
address_two = StringField("Line 2", validators=[Optional()])
city = StringField("City", validators=[Optional()])
state = SelectField(
"State / U.S. Territory", choices=STATES, default="NY", validators=[Optional()]
)
zipcode = StringField(
"Zip Code (5 Digits)", validators=[Length(min=5, max=5), Optional()]
)

submit = SubmitField("Update OpenRecords Account")

def __init__(self, user=None):
"""
Expand All @@ -139,33 +146,36 @@ def autofill(self):
if self.user is not None:
self.title.data = self.user.title
self.organization.data = self.user.organization
self.notification_email.data = self.user.notification_email or self.user.email
self.notification_email.data = (
self.user.notification_email or self.user.email
)
self.phone_number.data = self.user.phone_number
self.fax_number.data = self.user.fax_number
if self.user.mailing_address is not None:
self.address_one.data = self.user.mailing_address.get('address_one')
self.address_two.data = self.user.mailing_address.get('address_two')
self.city.data = self.user.mailing_address.get('city')
self.state.data = self.user.mailing_address.get('state')
self.zipcode.data = self.user.mailing_address.get('zip')
self.address_one.data = self.user.mailing_address.get("address_one")
self.address_two.data = self.user.mailing_address.get("address_two")
self.city.data = self.user.mailing_address.get("city")
self.state.data = self.user.mailing_address.get("state")
self.zipcode.data = self.user.mailing_address.get("zip")

def validate(self):
""" One mthod of contact must be provided. """
base_is_valid = super(ManageAgencyUserAccountForm, self).validate()
return base_is_valid and bool(
self.notification_email.data or
self.phone_number.data or
self.fax_number.data or
( # mailing address
self.address_one.data and
self.city.data and
self.state.data and
self.zipcode.data
))
self.notification_email.data
or self.phone_number.data
or self.fax_number.data
or ( # mailing address
self.address_one.data
and self.city.data
and self.state.data
and self.zipcode.data
)
)


class BasicLoginForm(Form):
email = StringField('Email')
password = PasswordField('Password')
email = StringField("Email")
password = PasswordField("Password")

login = SubmitField('Login')
login = SubmitField("Login")
11 changes: 11 additions & 0 deletions app/commands.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-
"""Click commands."""
import os
import sys
from glob import glob
from subprocess import call

import click
from flask import current_app
from flask.cli import with_appcontext
from werkzeug.exceptions import MethodNotAllowed, NotFound
1 change: 1 addition & 0 deletions app/constants/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
('OK', 'Oklahoma'),
('OR', 'Oregon'),
('PA', 'Pennsylvania'),
('PR', 'Puerto Rico'),
('RI', 'Rhode Island'),
('SC', 'South Carolina'),
('SD', 'South Dakota'),
Expand Down
Loading

0 comments on commit aed2a55

Please sign in to comment.