Skip to content
Draft
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
12 changes: 12 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# --- Database Credentials (Fixes DB Initialization Error) ---
POSTGRES_DB=deans_cms_db
POSTGRES_USER=deans_user
POSTGRES_PASSWORD=your_secure_db_password # <--- REPLACE ME

# --- API Secrets (Fixes SECRET_KEY exposure) ---
DJANGO_SECRET_KEY=a_new_secure_secret_for_django # <--- REPLACE ME

# --- Inter-Service Decoupling ---
# The Notification service name is 'deans-notification' in the parent repository structure,
# and it runs on a known port (e.g., 5000) within the Docker network.
NOTIFICATION_SERVICE_URL=http://deans-notification:5000
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,7 @@ venv.bak/

migrations/
tidb/
.env

# Environment variables for local deployment
.env
9 changes: 0 additions & 9 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +0,0 @@
[submodule "deans-api"]
path = deans-api
url = https://github.com/Deans-CMS/deans-api
[submodule "deans-frontend"]
path = deans-frontend
url = https://github.com/Deans-CMS/deans-frontend
[submodule "deans-notification"]
path = deans-notification
url = https://github.com/Deans-CMS/deans-notification.git
1 change: 0 additions & 1 deletion deans-api
Submodule deans-api deleted from dbfa6b
244 changes: 244 additions & 0 deletions deans-api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,244 @@
.idea/
.vscode
# Created by https://www.gitignore.io/api/macos,linux,django,python,pycharm

### Django ###
*.log
*.pot
*.pyc
__pycache__/
local_settings.py
db.sqlite3
media
static
### Linux ###
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

### macOS ###
*.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### PyCharm ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff:
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/dictionaries

# Sensitive or high-churn files:
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.xml
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml

# Gradle:
.idea/**/gradle.xml
.idea/**/libraries

# CMake
cmake-build-debug/

# Mongo Explorer plugin:
.idea/**/mongoSettings.xml

## File-based project format:
*.iws

## Plugin-specific files:

# IntelliJ
/out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

### PyCharm Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721

# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr

# Sonarlint plugin
.idea/sonarlint

### Python ###
# Byte-compiled / optimized / DLL files
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/

# Translations
*.mo

# Django stuff:

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# dotenv
.env

# virtualenv
.venv
venv/
ENV/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# End of https://www.gitignore.io/api/macos,linux,django,python,pycharm


#docker
.vagrant*
bin
docker/docker
.*.swp
a.out
*.orig
build_src
.flymake*
.idea
.DS_Store
docs/_build
docs/_static
docs/_templates
.gopath/
.dotcloud
*.test
bundles/
.hg/
.git/
vendor/pkg/
pyenv
Vagrantfile

migrations/
deans_api/.pytest_cache
deans_api/api/.pytest_cache
*.pytest_cache
8 changes: 8 additions & 0 deletions deans-api/.pytest_cache/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# pytest cache directory #

This directory contains data from the pytest's cache plugin,
which provides the `--lf` and `--ff` options, as well as the `cache` fixture.

**Do not** commit this to version control.

See [the docs](https://docs.pytest.org/en/latest/cache.html) for more information.
1 change: 1 addition & 0 deletions deans-api/.pytest_cache/v/cache/nodeids
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
37 changes: 37 additions & 0 deletions deans-api/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM python:3.6

ENV PYTHONUNBUFFERED 1
ENV IN_DOCKER "1"
ENV BASEDIR /work
ENV DJANGO_ROOT $BASEDIR/deans-api/deans_api
ENV DATA_ROOT /data
ENV ENTRY_DIR $DJANGO_ROOT
ENV PATH "$DJANGO_ROOT:$BASEDIR:$PATH"
# RUN mkdir /code/deans-api

WORKDIR $BASEDIR

ADD debs/ $BASEDIR/
RUN dpkg -i *.deb

COPY ./start_django.sh $BASEDIR/
RUN chmod +x start_django.sh

ADD requirements.txt $BASEDIR/
RUN pip install -r requirements.txt
RUN sed -i -e 's/\r$//' start_django.sh
WORKDIR $BASEDIR
ADD ./deans_api $DJANGO_ROOT/
ADD ./data $DATA_DIR

WORKDIR $ENTRY_DIR
# CMD ["python3","$DJANGO_ROOT/manage.py", "runserver", "0.0.0.0:8000"]



# # cron
# RUN apt-get -y install cron
# COPY cron/* /etc/cron.d/
# RUN chmod 0644 /etc/cron.d/*
# RUN touch /var/log/cron.log
# # RUN service cron start
54 changes: 54 additions & 0 deletions deans-api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Dean's Crisis Management System


# Setup envirment

## On *nix

1. Install `docker` and `docker-compose` correctly.

[How to install on mac](http://sourabhbajaj.com/mac-setup/Docker/)

2. Setup python
```shell
$ virtualenv -p python3 env
$ source env/bin/activate
$ pip install -r requirments.txt
```

## On Windows
```
```

# Run server

If on Mac or Windows the container will run on Docker Machine which is a virtual machine, and will have its own ip address. You could run`docker-machine ip` to check the address, and such address will used to access the front end. However, on Linux, you could simplly access `localhost`.

## On *nux

If using you will need `sudo` to run the following command.
```shell
$ docker-compose up
```

## On Windows

```

```


# Useful commands

## Django migrattion

``` shell
docker-compose run web python manage.py migrate
```

# TODO

- [ ] persist data in a dockerized postgres database using volumes
- [ ] django-restful doc
- [ ] remove 'ADD' on setting page
- [ ]
2 changes: 2 additions & 0 deletions deans-api/cron/president-email-cron
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* * * * * root python3 /code/deans_api/manage.py runcrons >> /var/log/cron.log
# Mandatory blank line
Loading