Skip to content
This repository has been archived by the owner on Feb 24, 2021. It is now read-only.

Add House and HouseInformation model #15

Merged
merged 14 commits into from
Mar 26, 2019
Merged

Add House and HouseInformation model #15

merged 14 commits into from
Mar 26, 2019

Conversation

mcab
Copy link
Owner

@mcab mcab commented Feb 20, 2019

Addresses #5.

hiber/apps/bathouse/models.py Outdated Show resolved Hide resolved
watcher_first_name = models.CharField(max_length=50)
watcher_last_name = models.CharField(max_length=50)
email = models.EmailField(max_length=75)
longitude = models.CharField(max_length=20)
Copy link
Owner Author

Choose a reason for hiding this comment

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

Lines 7-8, we might not need to store it as just a string. I didn't realize that PostgreSQL has an extension to store point data (PostGIS, which is addressed in the Django docs). It might be easier to use a native format so that when we return this data over API, we know that there's enforcement that this should be a decimal-looking number.

Ultimately, this is your call.

hiber/apps/bathouse/models.py Outdated Show resolved Hide resolved
hiber/apps/bathouse/models.py Outdated Show resolved Hide resolved
hiber/apps/bathouse/models.py Outdated Show resolved Hide resolved
@mcab mcab changed the title Add House model Add House and HouseInformation model Feb 27, 2019
Older project happened to have some of the old choices. Edited some
choices that were split up to reflect what was in spec.

Added created / updated to House model to know when a House was created
or updated.
This is a fairly cool change.

We want to use longitude and latitude to keep track of a bat house. This
can be stored as a float, or, ideally, using PostGIS as a Point. This
allows for some further data processing (related to location) to better
map out bat houses.

This requires a PostGIS enabled system (changes in INSTALLED_APPS & the
migrations) as well as a database adapter to be aware of such.
@mcab mcab force-pushed the models/house branch 5 times, most recently from d482ed1 to a031257 Compare March 25, 2019 05:07
@mcab
Copy link
Owner Author

mcab commented Mar 25, 2019

Wow, that sucked.

For the record, CircleCI's Postgres images do install gdal-dev and gdal, but Django specifically looks for library files that GDAL uses.

This leads to having to install libgdal-dev so that Django does not fail when trying to execute.

django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library (tried "gdal", "GDAL", "gdal2.2.0", "gdal2.1.0", "gdal2.0.0", "gdal1.11.0", "gdal1.10.0", "gdal1.9.0"). Is GDAL installed? If it is, try setting GDAL_LIBRARY_PATH in your settings.
ERROR: InvocationError for command '/home/circleci/repo/.tox/py37/bin/pytest' (exited with code 1)

Would it be easier to use another image? Yes. But none suits the needs currently.

Right now, python-gdal seemed to be the best bet (same Python version we're testing against, newest GDAL), but does not have the tools CircleCI installs in their default images.

docker-geodjango installs a similar toolset to CircleCI's (as noted on StackOverflow), but uses Python 3.6. We could downgrade, but that's another can of worms to not open.

It's probably easiest to include a pull request to have Python 3.7 installed and not 3.6 to docker-geodjango, but it's even easier to just install the dependencies at run time, for now.


I tried:

  1. using a different PostGIS image (did not work)
  2. using wooyek/geodjango (too old of a Python version)
  3. bumping the version requirement for the CircleCI image (did not work, GDAL_LIBRARY_PATH not found)
  4. setting the environment variables for GDAL_LIBRARY_PATH (not the correct place to add to path)
  5. twice (still not the right dependency)
  6. Installing libgdal-dev directly (worked!)

@mcab
Copy link
Owner Author

mcab commented Mar 25, 2019

With that change, this closes #20, once it's merged in.

In order for Django to not claim there's nothing being set, we provide
sane defaults for town_name and property_type
@mcab mcab merged commit 195fca5 into develop Mar 26, 2019
@mcab mcab deleted the models/house branch March 26, 2019 02:38
This was referenced Mar 26, 2019
This was referenced Mar 26, 2019
mcab added a commit that referenced this pull request May 9, 2019
Co-authored-by: Samantha Gustafson <samantha.gustafson@uconn.edu>
Co-authored-by: Mark Cabanero <me@markcabanero.com>

Added models to keep track of data about Houses and information about
those houses. These are based off of a series of questions asked for
the environmental makeup around the bat house, as well as physical 
attributes of the bat house.

This also uses PostGIS now to keep track of the location of a bat house.
This required an updated PostgreSQL image for CircleCI.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant