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

Programmatically replace pickmybruin #74

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ supervisord.log
supervisord.pid
keys.py
.DS_Store
pickmybruin*.sql
bquest*.sql
18 changes: 9 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ default: build
clean:

build:
docker build -t pickmybruin/backend .
docker build -t bquest/backend .

run:
-pkill docker-compose
Expand All @@ -13,17 +13,17 @@ restart:
docker-compose restart web

ssh:
docker exec -i -t `docker ps -q --filter status=running --filter ancestor=pickmybruin/backend:latest` /bin/bash
docker exec -i -t `docker ps -q --filter status=running --filter ancestor=bquest/backend:latest` /bin/bash

# usage: make run_command cmd="echo hi"
run_command:
docker exec -i -t `docker ps -q --filter status=running --filter ancestor=pickmybruin/backend:latest` /bin/bash -c "$(cmd)"
docker exec -i -t `docker ps -q --filter status=running --filter ancestor=bquest/backend:latest` /bin/bash -c "$(cmd)"

shell:
docker exec -i -t `docker ps -q --filter status=running --filter ancestor=pickmybruin/backend:latest` /bin/bash -c "/code/src/manage.py shell_plus"
docker exec -i -t `docker ps -q --filter status=running --filter ancestor=bquest/backend:latest` /bin/bash -c "/code/src/manage.py shell_plus"

test:
docker exec -i -t `docker ps -q --filter status=running --filter ancestor=pickmybruin/backend:latest` /bin/bash -c "cd /code/src && ./manage.py test --no-input --parallel $(args)"
docker exec -i -t `docker ps -q --filter status=running --filter ancestor=bquest/backend:latest` /bin/bash -c "cd /code/src && ./manage.py test --no-input --parallel $(args)"

clean_db:
docker-compose exec db psql -U postgres -c 'DROP SCHEMA public CASCADE; CREATE SCHEMA public;'
Expand All @@ -35,12 +35,12 @@ init_db: clean_db
restore-db:

backup_db:
docker exec -t `docker ps -q --filter status=running --filter ancestor=postgres:10.1-alpine` pg_dumpall -c -U postgres > pickmybruin_dump_`date +%d-%m-%Y"_"%H_%M_%S`.sql
docker exec -t `docker ps -q --filter status=running --filter ancestor=postgres:10.1-alpine` pg_dumpall -c -U postgres > bquest_dump_`date +%d-%m-%Y"_"%H_%M_%S`.sql

save_requirements:
docker exec -i -t `docker ps -q --filter status=running --filter ancestor=pickmybruin/backend:latest` /bin/bash -c "pip3 freeze" | tail -n +2 > requirements.txt
docker exec -i -t `docker ps -q --filter status=running --filter ancestor=bquest/backend:latest` /bin/bash -c "pip3 freeze" | tail -n +2 > requirements.txt

install_package:
docker exec -i -t `docker ps -q --filter status=running --filter ancestor=pickmybruin/backend:latest` /bin/bash -c "pip3 install $(pkg)"
docker exec -i -t `docker ps -q --filter status=running --filter ancestor=pickmybruin/backend:latest` /bin/bash -c "pip3 freeze" | tail -n +2 > requirements.txt
docker exec -i -t `docker ps -q --filter status=running --filter ancestor=bquest/backend:latest` /bin/bash -c "pip3 install $(pkg)"
docker exec -i -t `docker ps -q --filter status=running --filter ancestor=bquest/backend:latest` /bin/bash -c "pip3 freeze" | tail -n +2 > requirements.txt

10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ Simplified tree diagram
``` /usr/bin/tree
. # Contains docker setup and Makefile
├── docker-compose.yml # defines setup of PostgreSQL and Django
├── Dockerfile # defines pickmybruin/backend Docker image
├── Dockerfile # defines bquest/backend Docker image
├── initialize.sh # sets up Django container (runs migrations and then boots server)
├── Makefile # contains very useful helper commands
└── src # Contains all Django code
├── pickmybruin # Contains code relating to the entire website
├── bquest # Contains code relating to the entire website
│   ├── keys.py # put confidential info in here
│   ├── settings.py # global settings (please keep confidential info out of here)
│   ├── urls.py # global URLs (usually imports app URLs too)
Expand All @@ -31,7 +31,7 @@ Simplified tree diagram
```

## Makefile commands
- `make build` creates the `pickmybruin/backend` image
- `make build` creates the `bquest/backend` image
- `make run` starts up the PostgreSQL and Django containers
- `make restart` restarts the Django container (useful when you edit code)
- `make ssh` starts a bash session in the latest Django container
Expand All @@ -44,12 +44,12 @@ Simplified tree diagram
## How to add a new app
1. Run `make run_command cmd="src/manage.py startapp $APPNAME`
- This creates a new skeleton folder for your new app
2. YOU MUST ADD THIS APP TO `src/pickmybruin/settings.py` `INSTALLED_APPS` FOR THE APP TO BE DISCOVEREDR
2. YOU MUST ADD THIS APP TO `src/bquest/settings.py` `INSTALLED_APPS` FOR THE APP TO BE DISCOVEREDR
- `'users',` adds the `users` app to the Django project. Big surprise.
3. Add your code
4. Add tests to `tests.py`
5. Add your models to `admin.py`
6. Import your urls.py in `src/pickmybruin/urls.py`
6. Import your urls.py in `src/bquest/urls.py`
7. Run the tests
8. Submit a PR

Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ services:
db:
image: postgres:10.1-alpine
websockets:
image: pickmybruin/websockets:latest
image: bquest/websockets:latest
build: websockets
ports:
- "8001:80"
web:
image: pickmybruin/backend:latest
image: bquest/backend:latest
build: .
command: bash initialize.sh
environment:
Expand Down
2 changes: 1 addition & 1 deletion init_db.sql
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,7 @@ COPY oauth2_provider_accesstoken (id, token, expires, scope, application_id, use
--

COPY oauth2_provider_application (id, client_id, redirect_uris, client_type, authorization_grant_type, client_secret, name, user_id, skip_authorization, created, updated) FROM stdin;
1 web confidential password sMXrq4RV2muu07ERhrllW1uCfH12U4ZNeqyM0L8bmaF9P59prjkIe5mhJJAt47Kod14yhRdg96gEf1m183sblRzyC175eLd7NzsyWS9w6QTyVPdczvTmeHiGBJJPjhGf pickmybruin web access \N f 2017-10-26 00:16:28.897+00 2017-11-02 07:56:52.99572+00
1 web confidential password sMXrq4RV2muu07ERhrllW1uCfH12U4ZNeqyM0L8bmaF9P59prjkIe5mhJJAt47Kod14yhRdg96gEf1m183sblRzyC175eLd7NzsyWS9w6QTyVPdczvTmeHiGBJJPjhGf bquest web access \N f 2017-10-26 00:16:28.897+00 2017-11-02 07:56:52.99572+00
\.


Expand Down
6 changes: 3 additions & 3 deletions initialize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@



if [ ! -f src/pickmybruin/keys.py ]; then
echo "SECRET_KEY = '"$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)"'" > src/pickmybruin/keys.py
echo $(pwd)"/src/pickmybruin/keys.py generated"
if [ ! -f src/bquest/keys.py ]; then
echo "SECRET_KEY = '"$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)"'" > src/bquest/keys.py
echo $(pwd)"/src/bquest/keys.py generated"
fi


Expand Down
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions src/pickmybruin/settings.py → src/bquest/settings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Django settings for pickmybruin project.
Django settings for bquest project.

For more information on this file, see
https://docs.djangoproject.com/en/1.6/topics/settings/
Expand Down Expand Up @@ -64,9 +64,9 @@
'corsheaders.middleware.CorsMiddleware',
)

ROOT_URLCONF = 'pickmybruin.urls'
ROOT_URLCONF = 'bquest.urls'

WSGI_APPLICATION = 'pickmybruin.wsgi.application'
WSGI_APPLICATION = 'bquest.wsgi.application'


# Database
Expand Down Expand Up @@ -113,7 +113,7 @@
AWS_S3_OBJECT_PARAMETERS = {
'CacheControl': 'max-age=86400',
}
DEFAULT_FILE_STORAGE = 'pickmybruin.storage_backends.MediaStorage'
DEFAULT_FILE_STORAGE = 'bquest.storage_backends.MediaStorage'
DATA_UPLOAD_MAX_NUMBER_FIELDS = None # ignores number of parameters sent

TEMPLATES = [
Expand Down Expand Up @@ -148,7 +148,7 @@
],
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.BasicAuthentication',
'pickmybruin.middleware.CsrfExemptSessionAuthentication',
'bquest.middleware.CsrfExemptSessionAuthentication',
),
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination',
'PAGE_SIZE': 100,
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/pickmybruin/wsgi.py → src/bquest/wsgi.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
WSGI config for pickmybruin project.
WSGI config for bquest project.

It exposes the WSGI callable as a module-level variable named ``application``.

Expand All @@ -8,7 +8,7 @@
"""

import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pickmybruin.settings")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "bquest.settings")

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
2 changes: 1 addition & 1 deletion src/email_requests/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ class RequestSerializer(WritableNestedModelSerializer):
class Meta:
model = Request
fields = ('mentee', 'mentor', 'email_body', 'preferred_mentee_email', 'phone', 'date_created',)
read_only_fields = ('mentee', 'mentor', 'email_body', 'preferred_mentee_email', 'phone', 'date_created',)
read_only_fields = ('mentee', 'mentor', 'email_body', 'preferred_mentee_email', 'phone', 'date_created',)
2 changes: 1 addition & 1 deletion src/email_requests/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from users.models import Profile, Mentor, User
from .models import Request
from rest_framework import generics
from pickmybruin.settings import REQUEST_TEMPLATE
from bquest.settings import REQUEST_TEMPLATE

import sendgrid
from sendgrid.helpers.mail import Email, Content, Substitution, Mail
Expand Down
2 changes: 1 addition & 1 deletion src/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pickmybruin.settings")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "bquest.settings")

from django.core.management import execute_from_command_line

Expand Down
2 changes: 1 addition & 1 deletion src/messaging/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ class MessageAdmin(admin.ModelAdmin):

@admin.register(models.Thread)
class ThreadAdmin(admin.ModelAdmin):
pass
pass
2 changes: 1 addition & 1 deletion src/messaging/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ class Meta:
model = models.Message
thread = factory.SubFactory(ThreadFactory)
sender = factory.SelfAttribute('thread.profile_1')


2 changes: 1 addition & 1 deletion src/messaging/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from users.models import Profile, User
from rest_framework import generics
from rest_framework.views import APIView
from pickmybruin.settings import MESSAGING_TEMPLATE
from bquest.settings import MESSAGING_TEMPLATE

import sendgrid
from sendgrid.helpers.mail import Email, Content, Substitution, Mail
Expand Down
2 changes: 1 addition & 1 deletion src/users/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
url(r'^verify_link/?$', views.ResendVerifyUser.as_view(), name='verify_link'),
url(r'^password/?$', views.PasswordReset.as_view(), name='password_reset'),
url(r'^password_link/?$', views.SendPasswordReset.as_view(), name='password_reset_link'),
]
]
2 changes: 1 addition & 1 deletion src/users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

import sendgrid
from sendgrid.helpers.mail import Email, Content, Substitution, Mail
from pickmybruin.settings import USER_VERIFICATION_TEMPLATE, PASSWORD_RESET_TEMPLATE
from bquest.settings import USER_VERIFICATION_TEMPLATE, PASSWORD_RESET_TEMPLATE

class UserViewSet(viewsets.ModelViewSet):
"""
Expand Down