Skip to content

Commit 486e91b

Browse files
authored
Merge pull request #287 from hackupc/develop
DEVELOP TO MASTER
2 parents 1dc21fb + 730f468 commit 486e91b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+151342
-651
lines changed

.circleci/config.yml

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ workflows:
33
version: 2
44
test:
55
jobs:
6-
- build-3.7
7-
- build-3.8
8-
- build-3.9
6+
- build-3.10
97

108
jobs:
119
build-3.7: &test-template
@@ -54,3 +52,7 @@ jobs:
5452
<<: *test-template
5553
docker:
5654
- image: circleci/python:3.9
55+
build-3.10:
56+
<<: *test-template
57+
docker:
58+
- image: circleci/python:3.10

.dockerignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
db.sqlite3
2+
staticfiles
3+
*.template
4+
.env
5+
env
6+
.github
7+
.circleci
8+
tmp

.env.template

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
PROD_MODE="True"
2+
SECRET=""
3+
POSTGRES_DB="postgres"
4+
POSTGRES_USER="postgres"
5+
POSTGRES_PASSWORD="password"
6+
POSTGRES_HOST="db"
7+
SG_KEY=""
8+
TP_KEY=""
9+
DOMAIN=""
10+
IP_SERVER=""
11+
GOOGLE_RECAPTCHA_SECRET_KEY=""
12+
GOOGLE_RECAPTCHA_SITE_KEY=""
13+
CAS_SERVER=""
14+
OIDC_DISCOVERY_ENDPOINT=""
15+
POSTGRES_PORT="5432"
16+
MYHACKUPC_PORT="8000"
17+
GOOGLE_WALLET_ISSUER_ID=""
18+
GOOGLE_WALLET_CLASS_SUFFIX=""
19+
GOOGLE_WALLET_APPLICATION_CREDENTIALS="/path/to/credentials.json" # remember to allow read perms

.github/workflows/backendTest.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Deploy on BackendTest
2+
3+
on:
4+
push:
5+
branches:
6+
- 'develop'
7+
8+
jobs:
9+
build:
10+
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v1
15+
16+
- name: Git pull and rebuild docker
17+
uses: appleboy/ssh-action@master
18+
with:
19+
host: ${{ secrets.HOST }}
20+
username: ${{ secrets.USERNAME }}
21+
port: ${{ secrets.PORT }}
22+
key: ${{ secrets.SSHKEY }}
23+
script: ${{ secrets.SCRIPT }}

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ files/*
2626
cache/
2727
*.sh
2828

29-
.google-service.account.json
29+
.env
30+
.google-service.account.json

Dockerfile

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM python:3.10-alpine
2+
3+
RUN apk update && apk add postgresql-dev gcc python3-dev musl-dev
4+
5+
# set environment variables
6+
ENV PYTHONDONTWRITEBYTECODE 1
7+
ENV PYTHONUNBUFFERED 1
8+
9+
# Upgrade pip before installing dependencies
10+
RUN pip install --upgrade pip
11+
COPY requirements.txt requirements.txt
12+
# Add bin to path to avoid wanring
13+
ENV PATH="/home/biene/.local/bin:${PATH}"
14+
# Disable cache because it won't be used because it will be installed only when creating image
15+
RUN pip install --no-cache-dir -r requirements.txt
16+
17+
# Mounts the application code to the image
18+
COPY . code
19+
WORKDIR /code
20+
21+
# Generate static files in the container
22+
RUN python manage.py collectstatic --noinput
23+
24+
# Add crons from crontab django module to system cron
25+
RUN python manage.py crontab add

README.md

+2-19
Original file line numberDiff line numberDiff line change
@@ -30,33 +30,16 @@
3030

3131
Needs: Python 3.X, virtualenv
3232

33-
Stable at v. 3.8.10
33+
Stable at v. 3.10.X
3434

3535
- `git clone https://github.com/hackupc/myhackupc && cd myhackupc`
36-
- `virtualenv env --python=python3`
36+
- `virtualenv env --python=python3.10`
3737
- `source ./env/bin/activate`
3838
- `pip install -r requirements.txt`
3939
- (Optional) If using Postgres, set up the necessary environment variables for its usage before this step
4040
- `python manage.py migrate`
4141
- `python manage.py createsuperuser` (creates super user to manage all the app)
4242

43-
### FAQ
44-
**The library backports.zoneinfo fails to install**
45-
If you are experiencing an error similar to this one:
46-
47-
``
48-
ERROR: Could not build wheels for backports.zoneinfo, which is required to install pyproject.toml-based projects
49-
``
50-
51-
Plase make sure to use *Python **3.8.10***
52-
53-
54-
**The library Pillow fails to install**
55-
Ths did the trick (note the python and -m flag are placed in purpouse to make sure you install it using the correct virtualenv python version):
56-
```
57-
python -m pip install --upgrade Pillow
58-
```
59-
6043
### Dummy data
6144

6245
_Coming soon_

app/hackathon_variables.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# Hackathon timezone
1111
TIME_ZONE = 'CET'
1212
# This description will be used on the html and sharing meta tags
13-
HACKATHON_DESCRIPTION = 'Join us for BarcelonaTech\'s hackathon. 36h. May 12 - 14.'
13+
HACKATHON_DESCRIPTION = 'Join us for BarcelonaTech\'s hackathon. 36h. May 3 - 5.'
1414
# Domain where application is deployed, can be set by env variable
1515
HACKATHON_DOMAIN = os.environ.get('DOMAIN', None)
1616
HEROKU_APP_NAME = os.environ.get('HEROKU_APP_NAME', None)
@@ -40,11 +40,11 @@
4040
HACKATHON_GITHUB_REPO = 'https://github.com/hackupc/myhackupc/'
4141

4242
# (OPTIONAL) Applications deadline
43-
HACKATHON_APP_DEADLINE = timezone.datetime(2023, 5, 3, 23, 59, tzinfo=timezone.pytz.timezone(TIME_ZONE))
44-
VOLUNTEER_APP_DEADLINE = timezone.datetime(2023, 5, 9, 23, 59, tzinfo=timezone.pytz.timezone(TIME_ZONE))
45-
MENTOR_APP_DEADLINE = timezone.datetime(2023, 5, 1, 23, 59, tzinfo=timezone.pytz.timezone(TIME_ZONE))
43+
HACKATHON_APP_DEADLINE = timezone.datetime(2024, 5, 3, 23, 59, tzinfo=timezone.pytz.timezone(TIME_ZONE))
44+
VOLUNTEER_APP_DEADLINE = timezone.datetime(2024, 5, 9, 23, 59, tzinfo=timezone.pytz.timezone(TIME_ZONE))
45+
MENTOR_APP_DEADLINE = timezone.datetime(2024, 5, 1, 23, 59, tzinfo=timezone.pytz.timezone(TIME_ZONE))
4646
# (OPTIONAL) Online checkin activated
47-
ONLINE_CHECKIN = timezone.datetime(2022, 4, 29, 17, 00, tzinfo=timezone.pytz.timezone(TIME_ZONE))
47+
ONLINE_CHECKIN = timezone.datetime(2024, 4, 29, 17, 00, tzinfo=timezone.pytz.timezone(TIME_ZONE))
4848
# (OPTIONAL) When to arrive at the hackathon
4949
HACKATHON_ARRIVE = ''
5050

app/middlewares.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from backports import zoneinfo
1+
import zoneinfo
22
from django.utils import timezone
33

44

app/settings.py

+20-11
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030

3131
# Application definition
3232
INSTALLED_APPS = [
33+
"whitenoise.runserver_nostatic",
34+
'django_crontab',
3335
'django.contrib.admin',
3436
'django.contrib.auth',
3537
'django.contrib.contenttypes',
@@ -57,7 +59,7 @@
5759
'corsheaders',
5860
]
5961

60-
GOOGLE_WALLET_ENABLED=True #Set to false to disable google wallet
62+
GOOGLE_WALLET_ENABLED = False # Set to false to disable google wallet
6163

6264
if BAGGAGE_ENABLED:
6365
INSTALLED_APPS.append('baggage')
@@ -79,6 +81,7 @@
7981
'django.middleware.security.SecurityMiddleware',
8082
'django.contrib.sessions.middleware.SessionMiddleware',
8183
"corsheaders.middleware.CorsMiddleware",
84+
"whitenoise.middleware.WhiteNoiseMiddleware",
8285
'django.middleware.common.CommonMiddleware',
8386
'django.middleware.csrf.CsrfViewMiddleware',
8487
'django.contrib.auth.middleware.AuthenticationMiddleware',
@@ -126,14 +129,14 @@
126129
ssl_require=os.environ.get('DATABASE_SECURE', 'true').lower() != 'false',
127130
)
128131

129-
if os.environ.get('PG_PWD', None):
132+
if os.environ.get('POSTGRES_PASSWORD', None):
130133
DATABASES = {
131134
'default': {
132135
'ENGINE': 'django.db.backends.postgresql_psycopg2',
133-
'NAME': os.environ.get('PG_NAME', 'backend'),
134-
'USER': os.environ.get('PG_USER', 'backenduser'),
135-
'PASSWORD': os.environ.get('PG_PWD'),
136-
'HOST': os.environ.get('PG_HOST', 'localhost'),
136+
'NAME': os.environ.get('POSTGRES_DB', 'backend'),
137+
'USER': os.environ.get('POSTGRES_USER', 'backenduser'),
138+
'PASSWORD': os.environ.get('POSTGRES_PASSWORD'),
139+
'HOST': os.environ.get('POSTGRES_HOST', 'localhost'),
137140
'PORT': '5432',
138141
}
139142
}
@@ -191,14 +194,14 @@
191194
STATICFILES_DIRS = [
192195
os.path.join(BASE_DIR, os.path.join('app', "static")),
193196
]
194-
STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage'
197+
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
195198

196199
# Dev emails set up
197200
if os.environ.get('ADMIN_EMAIL', None):
198201
try:
199202
HACKATHON_DEV_EMAILS.append(os.environ['ADMIN_EMAIL'])
200203
except NameError:
201-
HACKATHON_DEV_EMAILS = [os.environ['ADMIN_EMAIL'],]
204+
HACKATHON_DEV_EMAILS = [os.environ['ADMIN_EMAIL'], ]
202205

203206
# File upload configuration
204207
MEDIA_ROOT = 'files'
@@ -292,9 +295,9 @@
292295
MAX_VOTES_TO_APP = 30
293296

294297
APPLICATION_EXPIRATION_TYPES = {
295-
'H': True, # Hacker allways expire, do not change this
296-
'M': MENTOR_EXPIRES, # Mentor can expire
297-
'V': VOLUNTEER_EXPIRES, # Volunteer can expire
298+
'H': True, # Hacker allways expire, do not change this
299+
'M': MENTOR_EXPIRES, # Mentor can expire
300+
'V': VOLUNTEER_EXPIRES, # Volunteer can expire
298301
}
299302

300303
MEALS_TOKEN = os.environ.get('MEALS_TOKEN', None)
@@ -324,3 +327,9 @@
324327
# Security
325328
SESSION_COOKIE_SECURE = CSRF_COOKIE_SECURE = not DEBUG
326329
SECURE_REFERRER_POLICY = "strict-origin-when-cross-origin"
330+
331+
# Cron configuration to expire invitations and reimbursements
332+
CRONJOBS = [
333+
('6 */2 * * *', 'django.core.management.call_command', ['expire_reimbursements']),
334+
('6 */2 * * *', 'django.core.management.call_command', ['expire_applications']),
335+
]

0 commit comments

Comments
 (0)