diff --git a/Dockerfile b/Dockerfile index 8d001dd6..6b84041d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,30 @@ -FROM python:2.7 +# getting the base Image +FROM python:3.6-slim-buster + MAINTAINER Ana Balica + EXPOSE 8000 +# Initializing the working directory WORKDIR /usr/src + RUN mkdir portal + RUN cd portal + +# Re-Initializing the working directory WORKDIR /usr/src/portal + +# Copy the requirement.txt for installing COPY requirements/prod.txt /usr/src/portal/requirements/prod.txt -RUN pip install -r requirements/prod.txt +COPY requirements/dev.txt /usr/src/portal/requirements/dev.txt + +# Installing the requirements +RUN pip install -r requirements/dev.txt +# Installing the GDAL Library +# RUN apt-get install python-gdal +RUN apt-get update +RUN apt-get install -y software-properties-common +RUN add-apt-repository ppa:ubuntugis/ppa +RUN apt-get install -y gdal-bin python-gdal python3-gdal diff --git a/README.md b/README.md index 8e666689..3fbbad3a 100644 --- a/README.md +++ b/README.md @@ -146,12 +146,30 @@ production at the moment. It may be configured to do so in the future. 1. **This step will require the Django SECRET_KEY.** Run `docker run -e SECRET_KEY=foobarbaz portal_web`. 1. Run `docker-compose run web python systers_portal/manage.py migrate`. + + * After above command now Run `docker-compose run web python systers_portal/manage.py makemigrations` + for complete migration and then re-run `docker-compose run web python systers_portal/manage.py migrate`. + * Note: If you face any error like **Docker cannot link or db not running** + then run the following command in another terminal `docker-compose up db` + and again run the above following command + 1. Run `docker-compose run web python systers_portal/manage.py cities_light` for downloading and importing data for django-cities-light. 1. *Optional:* Run `docker-compose run web python systers_portal/manage.py createsuperuser` if you wish to create a superuser to access the admin panel. + + For working with database open up new terminal and run `docker-compose run db bash` + and then run `psql -U postgres -d postgres -h db` to enter in postgres db. + Run `\dt` for checking tables and `\q` for exiting the postgres terminal + and stop the container's bash using CTRL+D. + +1. Navigate to `systers_portal/systers_portal/settings/base.py` file and change to `ALLOWED_HOST=['O.O.O.O']` + so that we can access the docker-container from any ip address. + 1. Run `docker-compose up` to start the webserver for the Django Systers Portal project. + * Note If you face any error like **portal_web cannot start service web** then run + following command `service docker restart` then again run the above following command 1. Systers Portal should be running on port 8000. * If you are on Linux, enter `http://0.0.0.0:8000` in your browser. * If you are using boot2docker on Windows or Mac OS X, enter diff --git a/docker-compose.yml b/docker-compose.yml index 57b83146..9b940c21 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,10 @@ db: image: postgres:9.4 + ports: + - "5432:5432" + environment: + - POSTGRES_HOST_AUTH_METHOD=trust + web: build: . command: python systers_portal/manage.py runserver 0.0.0.0:8000 @@ -10,5 +15,5 @@ web: links: - db environment: + - SECRET_KEY=foobarbaz - DJANGO_SETTINGS_MODULE=systers_portal.settings.docker - diff --git a/requirements/prod.txt b/requirements/prod.txt index ffa55dfd..09722269 100644 --- a/requirements/prod.txt +++ b/requirements/prod.txt @@ -15,4 +15,4 @@ django-apscheduler==0.4.1 git+https://github.com/Chive/django-multiupload.git#egg=django-multiupload geoip2==4.0.2 nltk==3.5 -gensim==3.8.3 +gensim==3.8.3 \ No newline at end of file diff --git a/systers_portal/community/models.py b/systers_portal/community/models.py index 4de0063f..3a7d83bf 100644 --- a/systers_portal/community/models.py +++ b/systers_portal/community/models.py @@ -83,28 +83,24 @@ def get_absolute_url(self): def has_changed_name(self): """Check if community has a new name - :return: True if community changed name, False otherwise """ return self.name != self.original_name def has_changed_admin(self): """Check if community has a new admin - :return: True if community changed admin, False otherwise """ return self.admin != self.original_admin def add_member(self, systers_user): """Add community member - :param systers_user: SystersUser objects """ self.members.add(systers_user) def remove_member(self, systers_user): """Remove community member - :param systers_user: SystersUser object :return: """ @@ -112,7 +108,6 @@ def remove_member(self, systers_user): def get_fields(self): """Get model fields of a Community object - :return: list of tuples (fieldname, fieldvalue) """ return [(field.name, getattr(self, field.name)) for field in @@ -120,7 +115,6 @@ def get_fields(self): def set_new_admin(self, new_admin): """Transfer the admin role from the old to the new admin - :param new_admin: SystersUser object new admin of the community :return: OK if setting was successful, NOT_MEMBER if settings was unsuccessful, since the new admin is not a member of the @@ -210,7 +204,6 @@ def __str__(self): def get_fields(self): """Get model fields of a RequestCommunity object - :return: list of tuples (fieldname, fieldvalue) """ return [(field.name, getattr(self, field.name)) for field in @@ -218,7 +211,6 @@ def get_fields(self): def get_verbose_fields(self): """Get verbose names of RequestCommunity object's model fields - :return: list of tuples (verbosefieldname, fieldvalue) """ diff --git a/systers_portal/community/views.py b/systers_portal/community/views.py index 89b260f6..56ef8b75 100644 --- a/systers_portal/community/views.py +++ b/systers_portal/community/views.py @@ -230,11 +230,9 @@ class CommunityLandingView(RedirectView): def get_redirect_url(self, *args, **kwargs): """Provide a redirect url based on the following conditions: - * if a Community has no pages, redirect to the news list views * if a Community has at least one page, redirect to the page with the - lowest order (aka first page) - """ + lowest order (aka first page)""" community = get_object_or_404(Community, slug=kwargs['slug']) community_pages = CommunityPage.objects.filter( community=community).order_by('order') @@ -293,17 +291,13 @@ def get_context_data(self, **kwargs): def get_community(self): """Overrides the method from CommunityMenuMixin to extract the current community. - - :return: Community object - """ + :return: Community object""" return self.object def get_page_slug(self): """Overrides the method from CommunityMenuMixin to extract the current page slug or the lack of it. - - :return: string CommunityPage slug - """ + :return: string CommunityPage slug""" return self.kwargs['page_slug']