Skip to content

Commit

Permalink
models fixes, db, docker
Browse files Browse the repository at this point in the history
  • Loading branch information
dom-inic committed Apr 3, 2024
1 parent 96999f1 commit 2101d09
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 27 deletions.
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]


2 changes: 1 addition & 1 deletion Dockerfile.prod
Original file line number Diff line number Diff line change
Expand Up @@ -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 #
Expand Down
9 changes: 9 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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.
19 changes: 15 additions & 4 deletions conshareapi/settings/base.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,51 @@
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']


# 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',
Expand Down
14 changes: 6 additions & 8 deletions conshareapi/settings/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -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': {
Expand Down
12 changes: 6 additions & 6 deletions conshareapi/settings/prod.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions users/migrations/0004_alter_userprofile_certifications.py
Original file line number Diff line number Diff line change
@@ -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'),
),
]
34 changes: 34 additions & 0 deletions users/migrations/0005_alter_userprofile_education_and_more.py
Original file line number Diff line number Diff line change
@@ -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'),
),
]
10 changes: 5 additions & 5 deletions users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 2101d09

Please sign in to comment.