diff --git a/Dockerfile b/Dockerfile index 211f408..88b1399 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,11 +24,11 @@ RUN pip install --no-cache-dir -r requirements.txt # copy entrypoint.sh COPY ./entrypoint.sh . -RUN sed -i 's/\r$//g' /usr/src/app/entrypoint.sh -RUN chmod +x /usr/src/app/entrypoint.sh +RUN sed -i 's/\r$//g' /usr/src/coonshareapi3.0/entrypoint.sh +RUN chmod +x /usr/src/coonshareapi3.0/entrypoint.sh # run entrypoint.sh -ENTRYPOINT ["/usr/src/app/entrypoint.sh"] +ENTRYPOINT ["/usr/src/coonshareapi3.0/entrypoint.sh"] diff --git a/Dockerfile.prod b/Dockerfile.prod index 9137e0d..a9cb631 100644 --- a/Dockerfile.prod +++ b/Dockerfile.prod @@ -32,7 +32,7 @@ RUN flake8 --ignore=E501,F401 . # install python dependencies COPY ./requirements.txt . -RUN pip wheel --no-cache-dir --no-deps --wheel-dir /usr/src/app/wheels -r requirements.txt +RUN pip wheel --no-cache-dir --no-deps --wheel-dir /usr/src/coonshareapi3.0/wheels -r requirements.txt ######### # FINAL # diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..3a31363 --- /dev/null +++ b/LICENSE @@ -0,0 +1,9 @@ + +The MIT License (MIT) +Copyright (c) 2024, dominic + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/conshareapi/settings/base.py b/conshareapi/settings/base.py index 0f211e9..86e21ca 100644 --- a/conshareapi/settings/base.py +++ b/conshareapi/settings/base.py @@ -1,12 +1,15 @@ from pathlib import Path import os from datetime import timedelta -# import django_heroku - +from dotenv import load_dotenv # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent.parent +load_dotenv(dotenv_path=os.path.join(BASE_DIR, '.env.dev')) + + +SECRET_KEY = os.environ['SECRET_KEY'] # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/ ALLOWED_HOSTS = ['127.0.0.1', 'conshareapi.herokuapp.com', '0.0.0.0'] @@ -14,27 +17,35 @@ # Application definition -INSTALLED_APPS = [ + +DJANGO_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', +] - +LOCAL_APPS = [ 'users.apps.UsersConfig', 'feed.apps.FeedConfig', 'discussion.apps.DiscussionConfig', 'message.apps.MessageConfig', 'notification.apps.NotificationConfig', +] +THIRD_PARTY_APPS = [ 'rest_framework', 'corsheaders', 'ckeditor', 'django_countries', + ] + +INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS + REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': ( 'rest_framework_simplejwt.authentication.JWTAuthentication', diff --git a/conshareapi/settings/dev.py b/conshareapi/settings/dev.py index 7924671..e4f5db0 100644 --- a/conshareapi/settings/dev.py +++ b/conshareapi/settings/dev.py @@ -3,20 +3,18 @@ # override base.py settings DEBUG = bool(os.environ.get("DEBUG", default=0)) -SECRET_KEY = os.environ.get("SECRET_KEY") EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' DATABASES = { 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': os.environ.get("SQL_DATABASE", BASE_DIR / "db.sqlite3"), - 'ENGINE': os.environ.get("SQL_ENGINE", "django.db.backends.sqlite3"), - 'USER': os.environ.get("SQL_USER", "user"), - 'PASSWORD': os.environ.get("SQL_PASSWORD", "password"), - 'HOST': os.environ.get("SQL_HOST", "localhost"), - 'PORT': '5432', + 'ENGINE': 'django.db.backends.postgresql', + 'NAME': os.environ['SQL_DATABASE'], + 'USER': os.environ['SQL_USER'], + 'PASSWORD': os.environ['SQL_PASSWORD'], + 'HOST': os.environ['SQL_HOST'], + 'PORT': os.environ['PORT'], }, 'message': { diff --git a/conshareapi/settings/prod.py b/conshareapi/settings/prod.py index 3c34216..833e9f0 100644 --- a/conshareapi/settings/prod.py +++ b/conshareapi/settings/prod.py @@ -32,18 +32,18 @@ DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', - 'NAME': os.environ.get('consharedbname'), - 'USER': os.environ.get('conshare user'), - 'PASSWORD': os.environ.get('consharedbpass'), - 'HOST': os.environ.get('consharehost'), - 'PORT': '5432', + 'NAME': os.environ['SQL_DATABASE'], + 'USER': os.environ['SQL_USER'], + 'PASSWORD': os.environ['SQL_PASSWORD'], + 'HOST': os.environ['SQL_HOST'], + 'PORT': os.environ['PORT'], + }, 'message': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': BASE_DIR / 'messages.sqlite3', } } - # EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' # EMAIL_HOST = 'smtp.mailgun.org' # EMAIL_PORT = 587 diff --git a/users/migrations/0004_alter_userprofile_certifications.py b/users/migrations/0004_alter_userprofile_certifications.py new file mode 100644 index 0000000..9c252bb --- /dev/null +++ b/users/migrations/0004_alter_userprofile_certifications.py @@ -0,0 +1,19 @@ +# Generated by Django 4.0 on 2024-04-03 17:57 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0003_remove_userprofile_certifications_and_more'), + ] + + operations = [ + migrations.AlterField( + model_name='userprofile', + name='certifications', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='licenses', to='users.certificationtag'), + ), + ] diff --git a/users/migrations/0005_alter_userprofile_education_and_more.py b/users/migrations/0005_alter_userprofile_education_and_more.py new file mode 100644 index 0000000..7b00cae --- /dev/null +++ b/users/migrations/0005_alter_userprofile_education_and_more.py @@ -0,0 +1,34 @@ +# Generated by Django 4.0 on 2024-04-03 18:00 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0004_alter_userprofile_certifications'), + ] + + operations = [ + migrations.AlterField( + model_name='userprofile', + name='education', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='schools', to='users.educationtag'), + ), + migrations.AlterField( + model_name='userprofile', + name='interests', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='topic_interests', to='users.interesttag'), + ), + migrations.AlterField( + model_name='userprofile', + name='jobs', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='jobs_done', to='users.experiencetag'), + ), + migrations.AlterField( + model_name='userprofile', + name='skills', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='personal_skills', to='users.skilltag'), + ), + ] diff --git a/users/models.py b/users/models.py index e07756e..29e8470 100644 --- a/users/models.py +++ b/users/models.py @@ -83,11 +83,11 @@ class UserProfile(models.Model): city = models.CharField(max_length=100) vote_ratio = models.IntegerField(blank=True, null=True, default=0) followers_count = models.IntegerField(blank=True, null=True, default=0) - skills = models.ForeignKey(SkillTag, related_name='personal_skills', blank=True, on_delete=models.CASCADE) - interests = models.ForeignKey(InterestTag, related_name='topic_interests', blank=True, on_delete=models.CASCADE) - certifications = models.ForeignKey(CertificationTag, related_name='licenses', blank=True, on_delete=models.CASCADE) - jobs = models.ForeignKey(ExperienceTag, related_name='jobs_done', blank=True, on_delete=models.CASCADE) - education = models.ForeignKey(EducationTag, related_name='schools', blank=True, on_delete=models.CASCADE) + skills = models.ForeignKey(SkillTag, related_name='personal_skills', blank=True, null=True, on_delete=models.CASCADE) + interests = models.ForeignKey(InterestTag, related_name='topic_interests', blank=True, null=True, on_delete=models.CASCADE) + certifications = models.ForeignKey(CertificationTag, related_name='licenses', blank=True, null=True, on_delete=models.CASCADE) + jobs = models.ForeignKey(ExperienceTag, related_name='jobs_done', blank=True, null=True, on_delete=models.CASCADE) + education = models.ForeignKey(EducationTag, related_name='schools', blank=True, null=True, on_delete=models.CASCADE) followers = models.ManyToManyField(User, related_name='following', blank=True) email_verified = models.BooleanField(default=False) id = models.UUIDField(default=uuid.uuid4, unique=True, primary_key=True, editable=False)