Skip to content
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

Documentation for those who fork #204

Open
dscotese opened this issue Jun 24, 2018 · 17 comments
Open

Documentation for those who fork #204

dscotese opened this issue Jun 24, 2018 · 17 comments

Comments

@dscotese
Copy link

dscotese commented Jun 24, 2018

I started documenting what I'm learning about Maps4All in the Wiki on my fork. When that documentation is available through h4i's M4A project (for example, on the Wiki page which currently simply redirects back to the project page), this issue can be closed. Or at any time H4i deems it should be closed, of course :-)

@paulowe
Copy link

paulowe commented Feb 17, 2021

Hey @dscotese how did you deploy your fork? Any chance you can direct me / update the wiki ?

maps4all.org url doesn't seem to be working any longer

@dscotese
Copy link
Author

I did it on Linux and it was a long time ago. If you tell me what happens when you follow one of the steps in the main Readme (for the h4i project, not mine) and it doesn't have the effect you expected, I might remember how I got around or fixed that.

@paulowe
Copy link

paulowe commented Feb 17, 2021

Sure, thanks!

@paulowe
Copy link

paulowe commented Feb 18, 2021

I did it on Linux and it was a long time ago. If you tell me what happens when you follow one of the steps in the main Readme (for the h4i project, not mine) and it doesn't have the effect you expected, I might remember how I got around or fixed that.

Do you happen to know how to make account/reset-password and admin/invite-user routes to work. I keep getting an internal server error when accessing these routes/performing these functions.
Here are my Heroku logs:

Reset Password

I compared our source code and they seem to have the same way of handling reset password. I'm not sure if you also faced this issue?

2021-02-18T12:35:14.107194+00:00 app[web.1]: [2021-02-18 12:35:14,105] ERROR in app: Exception on /account/reset-password [GET]
2021-02-18T12:35:14.107205+00:00 app[web.1]: Traceback (most recent call last):
2021-02-18T12:35:14.107206+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 2447, in wsgi_app
2021-02-18T12:35:14.107206+00:00 app[web.1]: response = self.full_dispatch_request()
2021-02-18T12:35:14.107207+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 1952, in full_dispatch_request
2021-02-18T12:35:14.107228+00:00 app[web.1]: rv = self.handle_user_exception(e)
2021-02-18T12:35:14.107231+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 1821, in handle_user_exception
2021-02-18T12:35:14.107231+00:00 app[web.1]: reraise(exc_type, exc_value, tb)
2021-02-18T12:35:14.107232+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise
2021-02-18T12:35:14.107233+00:00 app[web.1]: raise value
2021-02-18T12:35:14.107233+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 1950, in full_dispatch_request
2021-02-18T12:35:14.107234+00:00 app[web.1]: rv = self.dispatch_request()
2021-02-18T12:35:14.107234+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 1936, in dispatch_request

2021-02-18T12:35:14.107235+00:00 app[web.1]: return self.view_functionsrule.endpoint
2021-02-18T12:35:14.107235+00:00 app[web.1]: File "/app/app/account/views.py", line 60, in reset_password_request
2021-02-18T12:35:14.107236+00:00 app[web.1]: if not current_user.is_anonymous():
2021-02-18T12:35:14.107243+00:00 app[web.1]: TypeError: 'bool' object is not callable

2021-02-18T12:35:14.107397+00:00 app[web.1]: Exception on /account/reset-password [GET]
2021-02-18T12:35:14.107398+00:00 app[web.1]: Traceback (most recent call last):
2021-02-18T12:35:14.107398+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 2447, in wsgi_app
2021-02-18T12:35:14.107398+00:00 app[web.1]: response = self.full_dispatch_request()
2021-02-18T12:35:14.107399+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 1952, in full_dispatch_request
2021-02-18T12:35:14.107399+00:00 app[web.1]: rv = self.handle_user_exception(e)
2021-02-18T12:35:14.107399+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 1821, in handle_user_exception
2021-02-18T12:35:14.107399+00:00 app[web.1]: reraise(exc_type, exc_value, tb)
2021-02-18T12:35:14.107400+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise
2021-02-18T12:35:14.107400+00:00 app[web.1]: raise value
2021-02-18T12:35:14.107400+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 1950, in full_dispatch_request
2021-02-18T12:35:14.107401+00:00 app[web.1]: rv = self.dispatch_request()
2021-02-18T12:35:14.107401+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 1936, in dispatch_request
2021-02-18T12:35:14.107401+00:00 app[web.1]: return self.view_functionsrule.endpoint

2021-02-18T12:35:14.107402+00:00 app[web.1]: File "/app/app/account/views.py", line 60, in reset_password_request
2021-02-18T12:35:14.107402+00:00 app[web.1]: if not current_user.is_anonymous():
2021-02-18T12:35:14.107404+00:00 app[web.1]: TypeError: 'bool' object is not callable

2021-02-18T12:35:14.363930+00:00 app[web.1]: --- Logging error ---
2021-02-18T12:35:14.364472+00:00 app[web.1]: Traceback (most recent call last):
2021-02-18T12:35:14.364663+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 2447, in wsgi_app
2021-02-18T12:35:14.364664+00:00 app[web.1]: response = self.full_dispatch_request()
2021-02-18T12:35:14.364831+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 1952, in full_dispatch_request
2021-02-18T12:35:14.364832+00:00 app[web.1]: rv = self.handle_user_exception(e)
2021-02-18T12:35:14.364912+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 1821, in handle_user_exception
2021-02-18T12:35:14.364912+00:00 app[web.1]: reraise(exc_type, exc_value, tb)
2021-02-18T12:35:14.364984+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise
2021-02-18T12:35:14.364984+00:00 app[web.1]: raise value
2021-02-18T12:35:14.365103+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 1950, in full_dispatch_request
2021-02-18T12:35:14.365104+00:00 app[web.1]: rv = self.dispatch_request()
2021-02-18T12:35:14.365192+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 1936, in dispatch_request
2021-02-18T12:35:14.365192+00:00 app[web.1]: return self.view_functionsrule.endpoint

2021-02-18T12:35:14.365238+00:00 app[web.1]: File "/app/app/account/views.py", line 60, in reset_password_request
2021-02-18T12:35:14.365239+00:00 app[web.1]: if not current_user.is_anonymous():
2021-02-18T12:35:14.365405+00:00 app[web.1]: TypeError: 'bool' object is not callable

2021-02-18T12:35:14.365521+00:00 app[web.1]:
2021-02-18T12:35:14.365522+00:00 app[web.1]: During handling of the above exception, another exception occurred:
2021-02-18T12:35:14.365523+00:00 app[web.1]:
2021-02-18T12:35:14.365595+00:00 app[web.1]: Traceback (most recent call last):
2021-02-18T12:35:14.365886+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/logging/handlers.py", line 1023, in emit
2021-02-18T12:35:14.365887+00:00 app[web.1]: smtp.send_message(msg)
2021-02-18T12:35:14.366007+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/smtplib.py", line 967, in send_message
2021-02-18T12:35:14.366008+00:00 app[web.1]: rcpt_options)
2021-02-18T12:35:14.366012+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/smtplib.py", line 888, in sendmail

2021-02-18T12:35:14.366013+00:00 app[web.1]: raise SMTPDataError(code, resp)
2021-02-18T12:35:14.366064+00:00 app[web.1]: smtplib.SMTPDataError: (550, b'The from address does not match a verified Sender Identity. Mail cannot be sent until this error is resolved. Visit https://sendgrid.com/docs/for-developers/sending-email/sender-identity/ to see the Sender Identity requirements')

2021-02-18T12:35:14.366087+00:00 app[web.1]: Call stack:
2021-02-18T12:35:14.369539+00:00 app[web.1]: File "/app/.heroku/python/bin/gunicorn", line 8, in
2021-02-18T12:35:14.369540+00:00 app[web.1]: sys.exit(run())
2021-02-18T12:35:14.369560+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 58, in run
2021-02-18T12:35:14.369561+00:00 app[web.1]: WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
2021-02-18T12:35:14.369780+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 228, in run
2021-02-18T12:35:14.369781+00:00 app[web.1]: super().run()
2021-02-18T12:35:14.369785+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 72, in run
2021-02-18T12:35:14.369785+00:00 app[web.1]: Arbiter(self).run()
2021-02-18T12:35:14.369812+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 202, in run
2021-02-18T12:35:14.369813+00:00 app[web.1]: self.manage_workers()
2021-02-18T12:35:14.369835+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 545, in manage_workers
2021-02-18T12:35:14.369835+00:00 app[web.1]: self.spawn_workers()
2021-02-18T12:35:14.369882+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 616, in spawn_workers
2021-02-18T12:35:14.369883+00:00 app[web.1]: self.spawn_worker()
2021-02-18T12:35:14.369886+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
2021-02-18T12:35:14.369886+00:00 app[web.1]: worker.init_process()
2021-02-18T12:35:14.369887+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 140, in init_process
2021-02-18T12:35:14.369887+00:00 app[web.1]: self.run()
2021-02-18T12:35:14.369913+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/sync.py", line 123, in run
2021-02-18T12:35:14.369913+00:00 app[web.1]: self.run_for_one(timeout)
2021-02-18T12:35:14.369937+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/sync.py", line 67, in run_for_one
2021-02-18T12:35:14.369938+00:00 app[web.1]: self.accept(listener)
2021-02-18T12:35:14.369960+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/sync.py", line 29, in accept
2021-02-18T12:35:14.369960+00:00 app[web.1]: self.handle(listener, client, addr)
2021-02-18T12:35:14.369981+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/sync.py", line 134, in handle
2021-02-18T12:35:14.369982+00:00 app[web.1]: self.handle_request(listener, req, client, addr)
2021-02-18T12:35:14.369985+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/sync.py", line 175, in handle_request
2021-02-18T12:35:14.369986+00:00 app[web.1]: respiter = self.wsgi(environ, resp.start_response)
2021-02-18T12:35:14.370018+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 2464, in call
2021-02-18T12:35:14.370019+00:00 app[web.1]: return self.wsgi_app(environ, start_response)
2021-02-18T12:35:14.370022+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 2450, in wsgi_app
2021-02-18T12:35:14.370023+00:00 app[web.1]: response = self.handle_exception(e)
2021-02-18T12:35:14.370051+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 1871, in handle_exception
2021-02-18T12:35:14.370052+00:00 app[web.1]: self.log_exception((exc_type, exc_value, tb))
2021-02-18T12:35:14.370056+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 1892, in log_exception
2021-02-18T12:35:14.370056+00:00 app[web.1]: "Exception on %s [%s]" % (request.path, request.method), exc_info=exc_info

2021-02-18T12:35:14.370112+00:00 app[web.1]: Message: 'Exception on /account/reset-password [GET]'
2021-02-18T12:35:14.370113+00:00 app[web.1]: Arguments: ()
2021-02-18T12:35:14.415425+00:00 app[web.1]: 10.30.25.182 - - [18/Feb/2021:12:35:14 +0000] "GET /account/reset-password HTTP/1.1" 500 6230 "https://aif-mvp.herokuapp.com/account/login" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1 Safari/605.1.15"

Invite user / Sender identity verification

Note I have setup the Sendgrid addon and added API keys to config variables. I have also verified Sender identity. This is my worker process log right after I click the "Invite" button. (The web process log seems to work ok, it has 200 status codes). Maybe I am missing something in addition to the sender identity verification?

Screen Shot 2021-02-18 at 4 11 34 PM

2021-02-18T12:56:41.037456+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask_mail.py", line 492, in send
2021-02-18T12:56:41.037456+00:00 app[worker.1]: message.send(connection)
2021-02-18T12:56:41.037456+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask_mail.py", line 427, in send
2021-02-18T12:56:41.037457+00:00 app[worker.1]: connection.send(self)
2021-02-18T12:56:41.037457+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask_mail.py", line 192, in send
2021-02-18T12:56:41.037457+00:00 app[worker.1]: message.rcpt_options)
2021-02-18T12:56:41.037457+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/smtplib.py", line 888, in sendmail

2021-02-18T12:56:41.037458+00:00 app[worker.1]: raise SMTPDataError(code, resp)
2021-02-18T12:56:41.037466+00:00 app[worker.1]: smtplib.SMTPDataError: (550, b'The from address does not match a verified Sender Identity. Mail cannot be sent until this error is resolved. Visit https://sendgrid.com/docs/for-developers/sending-email/sender-identity/ to see the Sender Identity requirements')

2021-02-18T13:03:26.097815+00:00 app[worker.1]: 13:03:26 Cleaning registries for queue: default

Please let me know if you need any more info. My updated project is at https://github.com/paulowe/maps4resources

@paulowe
Copy link

paulowe commented Feb 18, 2021

I figured it out. I hadn't set one of the config variables in email.py

@dscotese
Copy link
Author

Which variable, in case someone else runs into it?

@paulowe
Copy link

paulowe commented Feb 19, 2021

Which variable, in case someone else runs into it?

In addition to the ADMIN_EMAIL and the Sendgrid config variables, you need to set EMAIL_SENDER config variable

@paulowe
Copy link

paulowe commented Mar 22, 2021

Hi @dscotese how did you relate resources to a locale and make them display on each locale's path http://www.resourcemap.org/national/ vs http://www.resourcemap.org/temecula-valley/ ?

I managed to setup your repository and get it to run. I am also using the Sqlite3 database to create all the tables. I created a locale table and added 2 locales. I also added a resource and made sure I assigned it the same ID as the locale I want to relate it to. The only issue is that none of the resources are displaying on the interface. Do I need to change anything else?

Thank you!

@dscotese
Copy link
Author

The Resource table (line 170 in Resource.py) has a field called locale_id (you mentioned "ID" and I suppose you meant "locale_id"). The path element "national" is hardcoded in that file too because it is handled specially. I can't remember how the database tables get created, but my impression is that the files in app/models/ are responsible for it. There are many aspects of this code that I don't feel I ever fully understood, and "Blueprint" is one of them. There is also a custom.js file that is loaded to alter the page after it loads, but I don't think that has anything to do with the question you're exploring.

The simple answer might be: "national" is a default kind of locale to display all the other locales, and the code that adds it (as a locale) to the database is in Resource.py.

Keep asking, as I'm interested in (re-)learning what I had to learn to get resourcemap.org into the state it's in.

@paulowe
Copy link

paulowe commented Mar 23, 2021

Hi @dscotese thank you, I believe the database is updating correctly. Here is a graphical view of the

  1. resource table

Screen Shot 2021-03-23 at 9 08 58 PM

  1. locale table

Screen Shot 2021-03-23 at 9 10 10 PM

  1. administrator dashboard (reflects the correct resources added in the db)

Screen Shot 2021-03-23 at 9 11 08 PM

But the issue is that none of the resources are being created as pins on the map for both locale paths

/national
Screen Shot 2021-03-23 at 9 12 20 PM

/new-locale
Screen Shot 2021-03-23 at 9 12 43 PM

Do you think it has something to do with code in resource.py and other files in the models folder? It seems like fetching data from database runs with status 200 so it should be ok, right?

Here is what I mean. This is the log generated after visiting localhost:5000/new-locale
Screen Shot 2021-03-23 at 9 21 46 PM

My guess would be this issue has something to do with rendering. Im not sure though. Any insights on how rendering works?
I tried examining this snippet of code in maps.js but I couldn't find specific issues to fix :/
Screen Shot 2021-03-23 at 9 26 23 PM

Thanks again for helping me out on this!

@paulowe
Copy link

paulowe commented Mar 23, 2021

The problem might actually be fetching from the database as you suggested because when I try to edit or view more details for a resource, I get this Key error that has something to do with 'locale_id'

127.0.0.1 - - [23/Mar/2021 23:21:19] "GET /NATIONAL/single_resource/2 HTTP/1.1" 500 -
23:21:19 web.1    | Traceback (most recent call last):
23:21:19 web.1    |   File "/Users/pcowe/.pyenv/versions/3.8.0/lib/python3.8/site-packages/flask/app.py", line 2464, in __call__
23:21:19 web.1    |     return self.wsgi_app(environ, start_response)
23:21:19 web.1    |   File "/Users/pcowe/.pyenv/versions/3.8.0/lib/python3.8/site-packages/flask/app.py", line 2450, in wsgi_app
23:21:19 web.1    |     response = self.handle_exception(e)
23:21:19 web.1    |   File "/Users/pcowe/.pyenv/versions/3.8.0/lib/python3.8/site-packages/flask/app.py", line 1867, in handle_exception
23:21:19 web.1    |     reraise(exc_type, exc_value, tb)
23:21:19 web.1    |   File "/Users/pcowe/.pyenv/versions/3.8.0/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
23:21:19 web.1    |     raise value
23:21:19 web.1    |   File "/Users/pcowe/.pyenv/versions/3.8.0/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app
23:21:19 web.1    |     response = self.full_dispatch_request()
23:21:19 web.1    |   File "/Users/pcowe/.pyenv/versions/3.8.0/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request
23:21:19 web.1    |     rv = self.handle_user_exception(e)
23:21:19 web.1    |   File "/Users/pcowe/.pyenv/versions/3.8.0/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception
23:21:19 web.1    |     reraise(exc_type, exc_value, tb)
23:21:19 web.1    |   File "/Users/pcowe/.pyenv/versions/3.8.0/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
23:21:19 web.1    |     raise value
23:21:19 web.1    |   File "/Users/pcowe/.pyenv/versions/3.8.0/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
23:21:19 web.1    |     rv = self.dispatch_request()
23:21:19 web.1    |   File "/Users/pcowe/.pyenv/versions/3.8.0/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
23:21:19 web.1    |     return self.view_functions[rule.endpoint](**req.view_args)
23:21:19 web.1    |   File "/Users/pcowe/.pyenv/versions/3.8.0/lib/python3.8/site-packages/flask_login/utils.py", line 272, in decorated_view
23:21:19 web.1    |     return func(*args, **kwargs)
23:21:19 web.1    |   File "/Users/pcowe/Desktop/maps4resources/app/single_resource/views.py", line 197, in edit
23:21:19 web.1    |     if form[field_name]:
23:21:19 web.1    |   File "/Users/pcowe/.pyenv/versions/3.8.0/lib/python3.8/site-packages/wtforms/form.py", line 64, in __getitem__
23:21:19 web.1    |     return self._fields[name]
23:21:19 web.1    | KeyError: 'locale_id'
23:21:19 web.1    | 127.0.0.1 - - [23/Mar/2021 23:21:19] "GET /NATIONAL/single_resource/2?__debugger__=yes&cmd=resource&f=style.css HTTP/1.1" 200 -
23:21:19 web.1    | 127.0.0.1 - - [23/Mar/2021 23:21:19] "GET /NATIONAL/single_resource/2?__debugger__=yes&cmd=resource&f=jquery.js HTTP/1.1" 200 -
23:21:19 web.1    | 127.0.0.1 - - [23/Mar/2021 23:21:19] "GET /NATIONAL/single_resource/2?__debugger__=yes&cmd=resource&f=debugger.js HTTP/1.1" 200 -
23:21:19 web.1    | 127.0.0.1 - - [23/Mar/2021 23:21:19] "GET /NATIONAL/single_resource/2?__debugger__=yes&cmd=resource&f=console.png HTTP/1.1" 200 -
23:21:20 web.1    | 127.0.0.1 - - [23/Mar/2021 23:21:20] "GET /NATIONAL/single_resource/2?__debugger__=yes&cmd=resource&f=ubuntu.ttf HTTP/1.1" 200 -

@dscotese
Copy link
Author

I wonder if you can get something to record the SQL request sent to server so you can see if "Key Error: locale_id" is coming from the SQL server. If you look at the network activity in the dev tools of a browser, you can see the request and make the request yourself to narrow down the system that needs to be debugged.

@paulowe
Copy link

paulowe commented Mar 24, 2021

  1. Network activity when I visit http://localhost:5000/national
    Note: get-resources/ (with status 308)

Screen Shot 2021-03-24 at 10 07 32 PM

Screen Shot 2021-03-24 at 10 17 54 PM

Screen Shot 2021-03-24 at 10 18 07 PM

On the chrome console this is what it shows:
Screen Shot 2021-03-24 at 10 37 59 PM

On the safari console this is what it shows:
Screen Shot 2021-03-24 at 10 44 10 PM

  1. Network activity when I try to view resource details at http://localhost:5000/national/single_resource/1
    Note: national/single_resource/1 now gives me an internal server error

Screen Shot 2021-03-24 at 10 21 46 PM

Screen Shot 2021-03-24 at 10 22 15 PM

Response:
Screen Shot 2021-03-24 at 10 35 35 PM

@paulowe
Copy link

paulowe commented Mar 30, 2021

@dscotese As per the images above, I figured the problem might be in map.js -> The syntax error is because resourcesString is HTML string instead of JSON object. I am not sure why this is the case because in main/views.py the get_resources() function is returning a JSON.

I tried messing around with map.js and instead of $.get('/get-resources).done(...) I hardcoded the locale name like so $.get('/national/get-resources).done(...) and it worked (displays the locales on the map). But the only issue is that when I click on the locale pin it directs me to resource info view, instead of opening a new map with its own set of pins/resources.

Another issue is that how can I dynamically change the /<locale>/get-resources in the Ajax request so that it requests and returns appropriate resources according to the locale in the url path? Is this even how you handle this kind of thing? I know you have something like <tlf> going on in the init.py files but I didn't really get this.

Any guidance would help a lot, thanks!

@dscotese
Copy link
Author

dscotese commented Apr 1, 2021

"tlf" means "top level folder." I think the answer might be that I did some things in the .htaccess file on our webserver and I can't remember them. I asked the owner for access just now because the credentials I have don't work.

@paulowe
Copy link

paulowe commented Apr 2, 2021

Hi @dscotese thanks! I was able to fix the issue. I edited code in map.js and views.py like so

main/views.py

Screen Shot 2021-04-01 at 8 04 33 PM

map.js
Screen Shot 2021-04-01 at 8 05 43 PM

Now it works ok. Im currently working on creating a GUI way of adding new locales, deleting locales -> and then I would connect them with the API u wrote.

@dscotese
Copy link
Author

dscotese commented May 1, 2021

Thanks for the update! I had hardcoded "national" (right?) as the tlf, and that is my bad. It had to be special because only one particular string, when used as the locale, should return the map of all other locales. I remember the feeling of "probably a bad idea, but who would want to use a string other than 'national' as their top level folder?" I think the owner of resourcemap.org is still struggling a bit with the motivation part of keeping the site alive. I like the maps4all project and glad you found value in it. Hopefully some others will come along and keep it alive too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants