-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Admin extensions #185
Merged
Merged
Admin extensions #185
Changes from 23 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
2e202fe
Whitespace
mjumbewu d3127d1
Add an admin page for adding/editing users.
mjumbewu a3b3521
Simplify the `UsersView` by using the `current_department` field dire…
mjumbewu ea41796
Correct a typo: change `UsersView` to `UserView`
mjumbewu 296d37b
Whitespace
mjumbewu ffc6b67
Get rid of unused import, `contextfunction`
mjumbewu 1043701
UNDO THIS COMMIT!
mjumbewu 178fe0c
Add better column labels to the user admin page
mjumbewu 2838210
Add ability for user to administer departments
mjumbewu 86e1480
Explain that contacts are just users
mjumbewu fddf0c0
Whitespace
mjumbewu ed8ca98
Update `User.department_id` field references
mjumbewu c927f35
Whitespace
mjumbewu 2bb599b
Undoing commit 1043701b
mjumbewu 61f731e
Add a link in the admin to export request data
mjumbewu 02f5f9d
Allow disabling `@login_required` via environment var
mjumbewu 9ee1feb
Give the records export data a filename
mjumbewu 82bbefb
Whitespace
mjumbewu 52c370b
Add a pretty string representation for owners and subscribers
mjumbewu 8811121
Use eager loading of owners and subscribers
mjumbewu fed1b92
Add post-date protection to admin
mjumbewu 45384c0
Whitespace
mjumbewu af60797
Add post date protection to the main UI
mjumbewu 27745b8
Correct the `is_supported_browser` method
mjumbewu 5851abe
Remove LOGIN_DISABLED environment setting
mjumbewu 8256dcc
Add an alembic migration for the User and Deparment models
mjumbewu 5599ac1
Require an extension reason before submitting
mjumbewu 7a9b0ac
Convert the Request.date_created column to UTC
mjumbewu 9c420e7
Show the requested time with on the case template
mjumbewu 89cd96f
Whitespace
mjumbewu ef33cd7
Display requested times in request list
mjumbewu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
from flask import Flask | ||
from flask.ext.sqlalchemy import SQLAlchemy | ||
|
||
# Initialize Flask app | ||
# Initialize Flask app | ||
app = Flask(__name__) | ||
app.debug = True | ||
|
||
|
@@ -24,9 +24,15 @@ def set_env(key, default = None): | |
elif default: | ||
app.config[key] = default | ||
|
||
def set_bool_env(key, default = None): | ||
if key in environ: | ||
app.config[key] = environ[key].lower() in ('true', 'yes', 'on') | ||
elif default is not None: | ||
app.config[key] = default | ||
|
||
# UPDATES TO THESE DEFAULTS SHOULD OCCUR IN YOUR .env FILE. | ||
|
||
set_env(key = 'APPLICATION_URL', default = "http://127.0.0.1:5000/") | ||
set_env(key = 'APPLICATION_URL', default = "http://127.0.0.1:5000/") | ||
set_env(key = 'ENVIRONMENT', default="LOCAL") | ||
# The default records liaison, to whom requests get routed to if no department is selected: | ||
set_env(key = 'DEFAULT_OWNER_EMAIL', default = '[email protected]') | ||
|
@@ -40,10 +46,12 @@ def set_env(key, default = None): | |
# Currently due dates and overdue status is only showed to logged in agency staff | ||
set_env(key = 'DAYS_TO_FULFILL', default = '10') | ||
set_env(key = 'DAYS_AFTER_EXTENSION', default = '14') | ||
set_env(key = 'DAYS_UNTIL_OVERDUE', default = '2') | ||
set_env(key = 'DAYS_UNTIL_OVERDUE', default = '2') | ||
|
||
set_env(key = 'TIMEZONE', default = "US/Pacific") | ||
|
||
set_bool_env(key = 'LOGIN_DISABLED', default = False) | ||
|
||
# Set rest of the variables that don't have defaults: | ||
envvars = [ | ||
'DEFAULT_MAIL_SENDER', # The e-mail address used as the FROM field for all notifications | ||
|
@@ -71,7 +79,7 @@ def set_env(key, default = None): | |
set_env(key = envvar) | ||
|
||
# Database gets set slightly differently, to support difference between Flask and Heroku naming: | ||
app.config['SQLALCHEMY_DATABASE_URI'] = environ['DATABASE_URL'] | ||
app.config['SQLALCHEMY_DATABASE_URI'] = environ['DATABASE_URL'] | ||
|
||
# Initialize database | ||
db = SQLAlchemy(app) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
""" | ||
""" | ||
.. module:: db_helpers | ||
:synopsis: Functions that interact with the Postgres database via Flask-SQLAlchemy | ||
.. modlueauthor:: Richa Agarwal <[email protected]> | ||
|
@@ -14,7 +14,7 @@ | |
import uuid | ||
import json | ||
import os | ||
import logging | ||
import logging | ||
|
||
|
||
### @export "get_subscriber" | ||
|
@@ -264,9 +264,9 @@ def update_user(user, alias = None, phone = None, department = None, contact_for | |
if type(department) != int and not department.isdigit(): | ||
d = Department.query.filter_by(name = department).first() | ||
if d: | ||
user.department = d.id | ||
user.department_id = d.id | ||
else: | ||
user.department = department | ||
user.department_id = department | ||
if contact_for: | ||
if user.contact_for and contact_for not in user.contact_for: | ||
contact_for = user.contact_for + "," + contact_for | ||
|
@@ -328,7 +328,7 @@ def add_staff_participant(request_id, is_point_person = False, email = None, use | |
participant.is_point_person = True | ||
participant.date_updated = datetime.now().isoformat() | ||
if reason: # Update the reason | ||
participant.reason = reason | ||
participant.reason = reason | ||
app.logger.info("\n\nStaff participant with owner ID: %s is now the point of contact for request %s" %(participant.id, request_id)) | ||
else: | ||
is_new = False | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it necessary to do this renaming? If so, a migration would be helpful.