Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
bf43971
Correct 'Chairman' to 'Chairperson'
mxmeinhold Sep 10, 2020
856c53e
Add time to packet end dates
mxmeinhold Sep 18, 2020
f64057d
Merge pull request #213 from ComputerScienceHouse/chairman-chairperson
mxmeinhold Sep 23, 2020
9377a65
Merge pull request #214 from ComputerScienceHouse/packet-dates
mxmeinhold Sep 23, 2020
232ab3f
Add local postgresql instructions
mxmeinhold Aug 28, 2020
bda5ecb
Create LDAPWrapper to enable local development
mxmeinhold Aug 30, 2020
872d127
Don't init onesignal if missing secrets
mxmeinhold Sep 25, 2020
44a2a8e
Expand initialisation logging to show state
mxmeinhold Sep 25, 2020
6c0c250
Merge pull request #216 from ComputerScienceHouse/local-dev
mxmeinhold Oct 7, 2020
de0373e
Let GitHub auto update deps in PRs
devinmatte Nov 2, 2020
8fa5939
Update psycopg2-binary requirement from ~=2.8.3 to ~=2.8.6 (#217)
dependabot[bot] Nov 2, 2020
203f230
Update sentry-sdk requirement from ~=0.14.2 to ~=0.19.1 (#221)
dependabot[bot] Nov 2, 2020
4f7be91
Update flask requirement from ~=1.1.0 to ~=1.1.2 (#218)
dependabot[bot] Nov 2, 2020
c0e31ad
Bump ini from 1.3.5 to 1.3.7 (#228)
dependabot[bot] Dec 22, 2020
28f406a
Update pylint requirement from ~=2.3.1 to ~=2.6.0 (#225)
dependabot[bot] Dec 22, 2020
602279e
Update gunicorn requirement from ~=19.7.1 to ~=20.0.4 (#220)
dependabot[bot] Dec 23, 2020
881dbc8
Create python-app.yml
devinmatte Dec 23, 2020
e4cba1c
Creating node and docker ci
devinmatte Dec 23, 2020
9b73d22
Update sentry-sdk requirement from ~=0.19.1 to ~=0.19.5 (#230)
dependabot[bot] Dec 23, 2020
d10b57a
Merge pull request #231 from ComputerScienceHouse/github-actions
devinmatte Dec 23, 2020
6765ba5
Update csh-ldap requirement from ~=2.1.0 to ~=2.3.1 (#229)
dependabot[bot] Dec 23, 2020
be5a666
Update flask-sqlalchemy requirement from ~=2.3.2 to ~=2.4.4 (#223)
dependabot[bot] Dec 25, 2020
182a5f2
Update flask-migrate requirement from ~=2.2.1 to ~=2.5.3 (#232)
dependabot[bot] Dec 25, 2020
9a706d2
Version bump to 3.5.2
mxmeinhold Jan 26, 2021
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
16 changes: 16 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "npm" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"

- package-ecosystem: "pip" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
32 changes: 32 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Docker

on:
push:
branches:
- develop
- master

# Run tests for any PRs.
pull_request:
branches:
- develop
- master

env:
IMAGE_NAME: packet

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Run tests
run: |
if [ -f docker-compose.test.yml ]; then
docker-compose --file docker-compose.test.yml build
docker-compose --file docker-compose.test.yml run sut
else
docker build . --file Dockerfile
fi
27 changes: 27 additions & 0 deletions .github/workflows/node-js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js CI

on:
push:
branches: [develop, master]
pull_request:
branches: [develop, master]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [10.x, 12.x, 14.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: yarn install
- run: yarn prod
34 changes: 34 additions & 0 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python application

on:
push:
branches: [master, develop]
pull_request:
branches: [master, develop]

jobs:
lint:
runs-on: ubuntu-latest

strategy:
matrix:
python-version: [3.7, 3.8]

steps:
- name: Install ldap dependencies
run: sudo apt-get install libldap2-dev libsasl2-dev
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with pylint
run: |
pylint packet
16 changes: 0 additions & 16 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM python:3.7-slim-buster
MAINTAINER Devin Matte <[email protected]>

RUN apt-get -yq update && \
apt-get -yq --no-install-recommends install gcc curl libsasl2-dev libldap2-dev libssl-dev && \
apt-get -yq --no-install-recommends install gcc curl libsasl2-dev libldap2-dev libssl-dev gnupg2 && \
apt-get -yq clean all

RUN mkdir /opt/packet
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,20 @@ If it doesn't work for some reason, you may have to globally install gulp throug
npm install -g gulp
```

### Local Development
* PostgreSQL
You'll need a postgres instance to use as a development DB.
You can use an existing database, like the instance used for the dev branch, use a database on another server, or spin up a container using docker or podman.
To get setup using docker, run
```bash
docker run --name packet-postgres -e POSTGRES_PASSWORD=mysecretpassword -d -p 5432:5432 postgres
```
After the container starts up, you should be able to connect with the connection string `postgresql://postgres:mysecretpassword@localhost:5432/postgres`, which is the default connection string in `config.env.py`.
Once the container is up, run the following to set up the database tables.
```bash
flask db upgrade
```

### Secrets and configuration
Packet supports 2 primary configuration methods:
1. Environment variables - See `config.env.py` for the expected names and default values.
Expand Down
17 changes: 15 additions & 2 deletions config.env.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
See the readme for more information
"""
from distutils.util import strtobool
from os import environ
from os import environ, path, getcwd

# Flask config
DEBUG = False
Expand All @@ -25,12 +25,25 @@
OIDC_CLIENT_SECRET = environ.get("PACKET_OIDC_CLIENT_SECRET", "PLEASE_REPLACE_ME")

# SQLAlchemy config
SQLALCHEMY_DATABASE_URI = environ.get("PACKET_DATABASE_URI", None)
SQLALCHEMY_DATABASE_URI = environ.get("PACKET_DATABASE_URI", "postgresql://postgres:mysecretpassword@localhost:5432/postgres")
SQLALCHEMY_TRACK_MODIFICATIONS = False

# LDAP config
LDAP_BIND_DN = environ.get("PACKET_LDAP_BIND_DN", None)
LDAP_BIND_PASS = environ.get("PACKET_LDAP_BIND_PASS", None)
LDAP_MOCK_MEMBERS = [
{'uid':'evals', 'groups': ['eboard', 'eboard-evaluations', 'active']},
{'uid':'imps-3da', 'groups': ['eboard', 'eboard-imps', '3da', 'active']},
{
'uid':'rtp-cm-webs-onfloor',
'groups': ['active-rtp', 'rtp', 'constitutional_maintainers', 'webmaster', 'active', 'onfloor'],
'room_number': 1024
},
{'uid':'misc-rtp', 'groups': ['rtp']},
{'uid':'onfloor', 'groups': ['active', 'onfloor'], 'room_number': 1024},
{'uid':'active-offfloor', 'groups': ['active']},
{'uid':'alum', 'groups': ['member']},
]

# Mail Config
MAIL_PROD = strtobool(environ.get("PACKET_MAIL_PROD", "False"))
Expand Down
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"title": "CSH Packet",
"name": "csh-packet",
"version": "3.5.1",
"version": "3.5.2",
"description": "A web app implementation of the CSH introductory packet.",
"bugs": {
"url": "https://github.com/ComputerScienceHouse/packet/issues",
Expand All @@ -13,6 +13,10 @@
"Joel Eager (https://github.com/JoelEager)",
"Max Meinhold (https://github.com/mxmeinhold)"
],
"scripts": {
"prod": "gulp production",
"lint": "gulp lint"
},
"repository": {
"type": "git",
"url": "https://github.com/ComputerScienceHouse/packet.git"
Expand Down
34 changes: 23 additions & 11 deletions packet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,29 +50,41 @@
app.config['OIDC_CLIENT_SECRET']))

# Initialize Onesignal Notification apps
csh_onesignal_client = onesignal.Client(user_auth_key=app.config['ONESIGNAL_USER_AUTH_KEY'],
app_auth_key=app.config['ONESIGNAL_CSH_APP_AUTH_KEY'],
app_id=app.config['ONESIGNAL_CSH_APP_ID'])

intro_onesignal_client = onesignal.Client(user_auth_key=app.config['ONESIGNAL_USER_AUTH_KEY'],
app_auth_key=app.config['ONESIGNAL_INTRO_APP_AUTH_KEY'],
app_id=app.config['ONESIGNAL_INTRO_APP_ID'])
csh_onesignal_client = None
if app.config['ONESIGNAL_USER_AUTH_KEY'] and \
app.config['ONESIGNAL_CSH_APP_AUTH_KEY'] and \
app.config['ONESIGNAL_CSH_APP_ID']:
csh_onesignal_client = onesignal.Client(
user_auth_key=app.config['ONESIGNAL_USER_AUTH_KEY'],
app_auth_key=app.config['ONESIGNAL_CSH_APP_AUTH_KEY'],
app_id=app.config['ONESIGNAL_CSH_APP_ID']
)
app.logger.info('CSH Onesignal configured and notifications enabled')

intro_onesignal_client = None
if app.config['ONESIGNAL_USER_AUTH_KEY'] and \
app.config['ONESIGNAL_INTRO_APP_AUTH_KEY'] and \
app.config['ONESIGNAL_INTRO_APP_ID']:
intro_onesignal_client = onesignal.Client(
user_auth_key=app.config['ONESIGNAL_USER_AUTH_KEY'],
app_auth_key=app.config['ONESIGNAL_INTRO_APP_AUTH_KEY'],
app_id=app.config['ONESIGNAL_INTRO_APP_ID']
)
app.logger.info('Intro Onesignal configured and notifications enabled')

# OIDC Auth
auth = OIDCAuthentication({'app': APP_CONFIG}, app)

# LDAP
_ldap = csh_ldap.CSHLDAP(app.config['LDAP_BIND_DN'], app.config['LDAP_BIND_PASS'])
app.logger.info('OIDCAuth configured')

# Sentry
sentry_sdk.init(
dsn=app.config['SENTRY_DSN'],
integrations=[FlaskIntegration(), SqlalchemyIntegration()]
)

app.logger.info('OIDCAuth and LDAP configured')

# pylint: disable=wrong-import-position
from .ldap import ldap
from . import models
from . import context_processors
from . import commands
Expand Down
5 changes: 2 additions & 3 deletions packet/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@
from functools import lru_cache
from datetime import datetime

from packet.ldap import ldap_get_member
from packet.models import Freshman
from packet import app
from packet import app, ldap


# pylint: disable=bare-except
@lru_cache(maxsize=128)
def get_csh_name(username):
try:
member = ldap_get_member(username)
member = ldap.get_member(username)
return member.cn + ' (' + member.uid + ')'
except:
return username
Expand Down
Loading