diff --git a/README.md b/README.md index 249b9eb..cb4734a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Maps4All [](https://circleci.com/gh/hack4impact/maps4all) [](https://codeclimate.com/github/hack4impact/maps4all) [](https://codeclimate.com/github/hack4impact/maps4all/coverage) [](https://codeclimate.com/github/hack4impact/maps4all) +# Maps4All [](https://circleci.com/gh/hack4impact/maps4all) [](https://codeclimate.com/github/hack4impact/maps4all) [](https://codeclimate.com/github/hack4impact/maps4all/coverage) [](https://codeclimate.com/github/hack4impact/maps4all) ## Team Members @@ -23,6 +23,16 @@ A generalized Flask application for displaying location-based resources on a map ## Setting up +If you have not yet done so, visit maps4all.org and create an account. This will guide you through the creation of your Heroku account and the installation of the Heroku tools. + +### Windows 10 + +To develop locally on Windows 10, we (@sbue and myself, independently) used Windows Subsystem for Linux and additionally installed Heroku CLI in Ubuntu terminal and deployed with the client. This runs the app on Heroku servers, but you can run it locally too. + +#### Editing local files + +Check https://superuser.com/questions/1083962/windows-linux-subsystem-accessing-files-outside-of-ubuntu to see how you can deal with the fact that Windows' "subsystem for Linux" doesn't work very well when you edit files the Linux subsystem will use directly from Windows. It's best to go through the bash shell to create or edit files. + ##### Clone the repo ``` @@ -31,7 +41,7 @@ $ cd maps4all ``` ##### Initialize a virtualenv - + ``` $ pip install virtualenv $ virtualenv -p python3 venv @@ -134,77 +144,77 @@ Then navigate to `http://localhost:5000` on your preferred browser to open the w ``` -├── Procfile -├── README.md -├── app -│ ├── __init__.py -│ ├── account -│ │ ├── __init__.py -│ │ ├── forms.py -│ │ └── views.py -│ ├── admin -│ │ ├── __init__.py -│ │ ├── forms.py -│ │ └── views.py -│ ├── assets -│ │ ├── scripts -│ │ │ ├── app.js -│ │ │ └── vendor -│ │ │ ├── jquery.min.js -│ │ │ ├── semantic.min.js -│ │ │ └── tablesort.min.js -│ │ └── styles -│ │ ├── app.scss -│ │ └── vendor -│ │ └── semantic.min.css -│ ├── assets.py -│ ├── decorators.py -│ ├── email.py -│ ├── main -│ │ ├── __init__.py -│ │ ├── errors.py -│ │ ├── forms.py -│ │ └── views.py -│ ├── models.py -│ ├── static -│ │ ├── fonts -│ │ │ └── vendor -│ │ ├── images -│ │ └── styles -│ │ └── app.css -│ ├── templates -│ │ ├── account -│ │ │ ├── email -│ │ │ ├── login.html -│ │ │ ├── manage.html -│ │ │ ├── register.html -│ │ │ ├── reset_password.html -│ │ │ └── unconfirmed.html -│ │ ├── admin -│ │ │ ├── index.html -│ │ │ ├── manage_user.html -│ │ │ ├── new_user.html -│ │ │ └── registered_users.html -│ │ ├── errors -│ │ ├── layouts -│ │ │ └── base.html -│ │ ├── macros -│ │ │ ├── form_macros.html -│ │ │ └── nav_macros.html -│ │ ├── main -│ │ │ └── index.html -│ │ └── partials -│ │ ├── _flashes.html -│ │ └── _head.html -│ └── utils.py -├── config.py -├── manage.py -├── requirements -│ ├── common.txt -│ └── dev.txt -└── tests - ├── test_basics.py - └── test_user_model.py +??? Procfile +??? README.md +??? app +? ??? __init__.py +? ??? account +? ? ??? __init__.py +? ? ??? forms.py +? ? ??? views.py +? ??? admin +? ? ??? __init__.py +? ? ??? forms.py +? ? ??? views.py +? ??? assets +? ? ??? scripts +? ? ? ??? app.js +? ? ? ??? vendor +? ? ? ??? jquery.min.js +? ? ? ??? semantic.min.js +? ? ? ??? tablesort.min.js +? ? ??? styles +? ? ??? app.scss +? ? ??? vendor +? ? ??? semantic.min.css +? ??? assets.py +? ??? decorators.py +? ??? email.py +? ??? main +? ? ??? __init__.py +? ? ??? errors.py +? ? ??? forms.py +? ? ??? views.py +? ??? models.py +? ??? static +? ? ??? fonts +? ? ? ??? vendor +? ? ??? images +? ? ??? styles +? ? ??? app.css +? ??? templates +? ? ??? account +? ? ? ??? email +? ? ? ??? login.html +? ? ? ??? manage.html +? ? ? ??? register.html +? ? ? ??? reset_password.html +? ? ? ??? unconfirmed.html +? ? ??? admin +? ? ? ??? index.html +? ? ? ??? manage_user.html +? ? ? ??? new_user.html +? ? ? ??? registered_users.html +? ? ??? errors +? ? ??? layouts +? ? ? ??? base.html +? ? ??? macros +? ? ? ??? form_macros.html +? ? ? ??? nav_macros.html +? ? ??? main +? ? ? ??? index.html +? ? ??? partials +? ? ??? _flashes.html +? ? ??? _head.html +? ??? utils.py +??? config.py +??? manage.py +??? requirements +? ??? common.txt +? ??? dev.txt +??? tests + ??? test_basics.py + ??? test_user_model.py ``` ## License diff --git a/app/admin/views.py b/app/admin/views.py index 31f05c4..9cc3543 100644 --- a/app/admin/views.py +++ b/app/admin/views.py @@ -346,6 +346,28 @@ def change_site_style(): app_name=SiteAttribute.get_value("ORG_NAME")) +@admin.route('/customize-site/script', methods=['GET', 'POST']) +@login_required +@admin_required +def add_javascript(): + """Add to a site's javascript.""" + if request.method == 'POST': + script_attr = SiteAttribute.get("EXTRA_SCRIPT") + + url = request.form['url'] + script_attr.value = url + + db.session.add(script_attr) + db.session.commit() + + flash('Custom javascript successfully uploaded or replaced.') + + return redirect(url_for('admin.customize_site')) + + return render_template('admin/customize_site.html', + app_name=SiteAttribute.get_value("ORG_NAME")) + + @admin.route('/customize-site/twilio', methods=['GET', 'POST']) @login_required def change_twilio_credentials(): diff --git a/app/assets/scripts/descriptor.js b/app/assets/scripts/descriptor.js index 1e7c9fd..645cf4e 100644 --- a/app/assets/scripts/descriptor.js +++ b/app/assets/scripts/descriptor.js @@ -27,7 +27,7 @@ $(document).ready(function () { // This is for the new descriptor page $("#desc_type").change(function() { - if ($(this).val() === "Option") { + if ($(this).val() === "option") { $("#values-div").show(); } else { $("#values-div").hide(); diff --git a/app/templates/admin/customize_site.html b/app/templates/admin/customize_site.html index 8a3d36c..55b1c67 100644 --- a/app/templates/admin/customize_site.html +++ b/app/templates/admin/customize_site.html @@ -7,6 +7,7 @@ ('admin.change_site_logo', 'Change logo'), ('admin.change_site_style', 'Change style'), ('admin.change_twilio_credentials', 'Change Twilio credentials'), + ('admin.add_javascript', 'Add Javascript'), ] %} {% macro navigation(items) %} @@ -49,6 +50,11 @@
| Name | {{ app_name }} |