Skip to content

Commit

Permalink
Merge branch 'master' into to_hackupc
Browse files Browse the repository at this point in the history
  • Loading branch information
Casassarnau authored Mar 22, 2020
2 parents 0a67ec5 + 13fa6e4 commit 1363b65
Show file tree
Hide file tree
Showing 214 changed files with 6,327 additions and 365 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[flake8]
exclude = build,.git,.tox,./django/utils/six.py,./django/conf/app_template/*,./tests/.env,./env,./app/settings.py,./*/migrations,./app/hackathon_variables.py
ignore = W601,F403
max-line-length = 119
max-line-length = 120
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ python:
- "3.6-dev" # 3.6 development branch
install: "pip install -r requirements.txt"
script:
- ./manage.py test
- flake8
27 changes: 17 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<br>
<p align="center">
<img alt="HackAssistant" src="https://avatars2.githubusercontent.com/u/33712329?s=200&v=4" width="200"/>
<img alt="HackUPC Fall 2016" src="app/static/img/[email protected]" width="100%"/>
</p>
<br>


[![Maintainability](https://api.codeclimate.com/v1/badges/dcf8e46541dbab5eb64f/maintainability)](https://codeclimate.com/github/HackAssistant/registration/maintainability)
[![CircleCI](https://circleci.com/gh/HackAssistant/registration/tree/master.svg?style=svg)](https://circleci.com/gh/HackAssistant/registration/tree/master)

📝 Hackathon registration server. Originally [HackUPC/backend](https://github.com/hackupc). With collaboration from [HackCU](https://github.com/hackcu). [Medium article](https://medium.com/hackcu/hackassistant-95d0f15c9199). [User Guide](USER_GUIDE.md)

📝 Registration for hackathons. Forked from [HackAssistant/registration](https://github.com/HackAssistant/registration). Previously known as hackupc/backend. [Medium article](https://medium.com/hackcu/hackassistant-95d0f15c9199). [User Guide](USER_GUIDE.md)


## Features

Expand All @@ -28,13 +27,13 @@
- (Optional) Automated slack invites on confirm #️⃣
- (Optional) MyMLH sign up 📥

**Demo**: http://registration.gerard.space (updated from master automatically. Running on Heroku free dyno)


## Setup

Needs: Python 3.X, virtualenv

- `git clone https://github.com/hackassistant/registration && cd registration`
- `git clone https://github.com/hackupc/registration && cd registration`
- `virtualenv env --python=python3`
- `source ./env/bin/activate`
- `pip install -r requirements.txt`
Expand All @@ -58,7 +57,12 @@ You can replace the email backend easily. See more [here](https://djangopackages
- **DOMAIN**(optional): Domain where app will be running. Default: localhost:8000
- **SL_TOKEN**(optional): Slack token to invite hackers automatically on confirmation. You can obtain it [here](https://api.slack.com/custom-integrations/legacy-tokens)
- **SL_TEAM**(optional): Slack team name (xxx on xxx.slack.com)
- **DROPBOX_OAUTH2_TOKEN**(optional): Enables Dropbox as file upload server instead of local computer. (See "Set up Dropbox storage for uploaded files" below)
- **DROPBOX_OAUTH2_TOKEN**(optional): Enables DropBox as file upload server instead of local computer. (See "Set up Dropbox storage for uploaded files" below)
- **SL_BOT_ID**(optional): Slack bot ID to send messages from.
- **SL_BOT_TOKEN**(optional): Slack bot token to send messages.
- **SL_BOT_CHANNEL**(optional): General channel to refer from the bot messages.
- **SL_BOT_DIRECTOR1**(optional): User ID of one of the directors.
- **SL_BOT_DIRECTOR2**(optional): User ID of the other director.
- **MLH_CLIENT_SECRET**(optional): Enables MyMLH as a sign up option. Format is `client_id@client_secret` (See "Set up MyMLH" below)


Expand Down Expand Up @@ -197,6 +201,7 @@ server {
location / {
include proxy_params;
proxy_pass http://unix:/home/user/project_folder/backend.sock;
client_max_body_size 5MB;
}
Expand Down Expand Up @@ -268,6 +273,8 @@ You can use this for your own hackathon. How?
- Colors and presentation: [app/static/css/main.css](app/static/css/main.css).
- Navbar & content/disposition: [app/templates/base.html](app/templates/base.html)
- Email base template: [app/templates/base_email.html](app/templates/base_email.html)
- Update favicon [app/static/](app/static/)


### Content

Expand All @@ -276,7 +283,7 @@ You can use this for your own hackathon. How?
You can update emails related to
- Applications (application invite, event ticket, last reminder) at [applications/templates/mails/](applications/templates/mails/)
- Reimbursements (reimbursement email, reject receipt) at [reimbursement/templates/mails/](reimbursement/templates/mails/)
- User registration (email verification, password reset) at [reimbursement/templates/mails/](reimbursement/templates/mails/)
- User registration (email verification, password reset) at [user/templates/mails/](user/templates/mails/)

#### Update hackathon variables
Check all available variables at [app/hackathon_variables.py.template](app/hackathon_variables.py.template).
Expand All @@ -295,7 +302,7 @@ If you need extra labels for your hackathon, you can change the model and add yo
# Want to Contribute?
Read these [guidelines](.github/CONTRIBUTING.md) carefully.

By making a contribution, in any form (including, but not limited to, Issues and Pull Requests), you agree to abide by the [Code of Conduct](.github/CODE_OF_CONDUCT.md). Report any incidents to [email protected] and appropriate action will be taken against the offender after investigation.
By making a contribution, in any form (including, but not limited to, Issues and Pull Requests), you agree to abide by the [Code of Conduct](.github/CODE_OF_CONDUCT.md). Report any incidents to [email protected] and appropriate action will be taken against the offender after investigation.

# License

Expand Down
1 change: 1 addition & 0 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"env": {
"DOMAIN": {
"description": "Custom domain where app will be running (ignore if deploying using Heroku default domain)",
"value": "{SET THIS}.herokuapp.com",
"required": false
},
"SECRET": {
Expand Down
80 changes: 52 additions & 28 deletions app/hackathon_variables.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# -*- coding: utf-8 -*-
# HACKATHON PERSONALIZATION
import os

from django.utils import timezone

HACKATHON_NAME = 'HackAssistant'
HACKATHON_NAME = 'HackUPC'
# What's the name for the application
HACKATHON_APPLICATION_NAME = 'HackAssistant registration'
HACKATHON_APPLICATION_NAME = 'My HackUPC'
# Hackathon timezone
TIME_ZONE = 'MST'
TIME_ZONE = 'CET'
# This description will be used on the html and sharing meta tags
HACKATHON_DESCRIPTION = 'HackAssistant is an organization to mantain ' \
'a few open-source projects related with hackathon management'
HACKATHON_DESCRIPTION = 'Join us for BarcelonaTech\'s hackathon. 700 hackers. 36h. October 11th-13th.'
# Domain where application is deployed, can be set by env variable
HACKATHON_DOMAIN = os.environ.get('DOMAIN', None)
HEROKU_APP_NAME = os.environ.get('HEROKU_APP_NAME', None)
Expand All @@ -19,44 +19,55 @@
elif not HACKATHON_DOMAIN:
HACKATHON_DOMAIN = 'localhost:8000'
# Hackathon contact email: where should all hackers contact you. It will also be used as a sender for all emails
HACKATHON_CONTACT_EMAIL = 'contact@gerard.space'
HACKATHON_CONTACT_EMAIL = 'contact@hackupc.com'
# Hackathon logo url, will be used on all emails
HACKATHON_LOGO_URL = 'https://avatars2.githubusercontent.com/u/33712329?s=200&v=4'
HACKATHON_LOGO_URL = 'https://my.hackupc.com/static/logo.png'

HACKATHON_OG_IMAGE = 'https://hackcu.org/img/hackcu_ogimage870x442.png'
HACKATHON_OG_IMAGE = 'https://hackupc.com/assets/img/hackupc-ogimage@2x.png?v=2018'
# (OPTIONAL) Track visits on your website
# HACKATHON_GOOGLE_ANALYTICS = 'UA-7777777-2'
# (OPTIONAL) Hackathon twitter user
HACKATHON_TWITTER_ACCOUNT = 'casassaez'
HACKATHON_GOOGLE_ANALYTICS = 'UA-69542332-2'
# (OPTIONAL) Hackathon Twitter user
HACKATHON_TWITTER_ACCOUNT = 'hackupc'
# (OPTIONAL) Hackathon Facebook page
HACKATHON_FACEBOOK_PAGE = 'casassaez'
HACKATHON_FACEBOOK_PAGE = 'hackupc'
# (OPTIONAL) Hackathon YouTube channel
HACKATHON_YOUTUBE_PAGE = 'UCiiRorGg59Xd5Sjj9bjIt-g'
# (OPTIONAL) Hackathon Instagram user
HACKATHON_INSTAGRAM_ACCOUNT = 'hackupc'
# (OPTIONAL) Hackathon Medium user
HACKATHON_MEDIUM_ACCOUNT = 'hackupc'
# (OPTIONAL) Github Repo for this project (so meta)
HACKATHON_GITHUB_REPO = 'https://github.com/hackassistant/registration/'
HACKATHON_GITHUB_REPO = 'https://github.com/hackupc/registration/'

# (OPTIONAL) Applications deadline
# HACKATHON_APP_DEADLINE = timezone.datetime(2018, 2, 24, 3, 14, tzinfo=timezone.pytz.timezone(TIME_ZONE))
HACKATHON_APP_DEADLINE = timezone.datetime(2019, 11, 6, 23, 59, tzinfo=timezone.pytz.timezone(TIME_ZONE))
# (OPTIONAL) When to arrive at the hackathon
HACKATHON_ARRIVE = 'Registration opens at 3:00 PM and closes at 6:00 PM on Friday October 13th, ' \
'the opening ceremony will be at 7:00 pm.'
HACKATHON_ARRIVE = 'Registration opens at 4:00PM and closes at 6:45PM on Friday October 11th, ' \
'the opening ceremony will be at 7:00PM.'

# (OPTIONAL) When to arrive at the hackathon
HACKATHON_LEAVE = 'Closing ceremony will be held on Sunday October 15th from 3:00 PM to 5:00 PM. ' \
'However the projects demo fair will be held in the morning from 10:30 AM to 1 PM.'
HACKATHON_LEAVE = 'Closing ceremony will be held on Sunday October 13th from 3:00PM to 5:00PM. ' \
'However judging will be happenning in the morning from 10:30AM to 1:00PM.'
# (OPTIONAL) Hackathon live page
# HACKATHON_LIVE_PAGE = 'https://gerard.space/live'
HACKATHON_LIVE_PAGE = 'https://hackupc.com/live'

# (OPTIONAL) Regex to automatically match organizers emails and set them as organizers when signing up
REGEX_HACKATHON_ORGANIZER_EMAIL = '^.*@gerard\.space$'
REGEX_HACKATHON_ORGANIZER_EMAIL = '^.*@hackupc\.com$'

# (OPTIONAL) Sends 500 errors to email whilst in production mode.
HACKATHON_DEV_EMAILS = []
# (OPTIONAL) Send 500 errors to email while on production mode
HACKATHON_DEV_EMAILS = ['[email protected]', ]

# Baggage configuration
BAGGAGE_ENABLED = True
BAGGAGE_PICTURE = True

# Reimbursement configuration
REIMBURSEMENT_ENABLED = True
CURRENCY = '$'
DEFAULT_REIMBURSEMENT_AMOUNT = 100
CURRENCY = '€'
REIMBURSEMENT_EXPIRY_DAYS = 5
REIMBURSEMENT_REQUIREMENTS = 'You have to submit a project and demo it during the event in order to be reimbursed.'
REIMBURSEMENT_DEADLINE = timezone.datetime(2018, 2, 24, 3, 14, tzinfo=timezone.pytz.timezone(TIME_ZONE))
REIMBURSEMENT_REQUIREMENTS = 'You have to submit a project and demo it during the event in order to get reimbursed'
REIMBURSEMENT_DEADLINE = timezone.datetime(2019, 9, 2, 3, 14, tzinfo=timezone.pytz.timezone(TIME_ZONE))

# (OPTIONAL) Max team members. Defaults to 4
TEAMS_ENABLED = True
Expand All @@ -75,13 +86,26 @@

# (OPTIONAL) Logged in cookie
# This allows to store an extra cookie in the browser to be shared with other application on the same domain
LOGGED_IN_COOKIE_DOMAIN = '.gerard.space'
LOGGED_IN_COOKIE_KEY = 'hackassistant_logged_in'
# LOGGED_IN_COOKIE_DOMAIN = '.gerard.space'
# LOGGED_IN_COOKIE_KEY = 'hackassistant_logged_in'

# Hardware configuration
HARDWARE_ENABLED = False
# Hardware request time length (in minutes)
HARDWARE_ENABLED = True
#Hardware request time length (in minutes)
HARDWARE_REQUEST_TIME = 15


SLACK_BOT = {
'id' : os.environ.get('SL_BOT_ID', None),
'token' : os.environ.get('SL_BOT_TOKEN', None),
'channel' : os.environ.get('SL_BOT_CHANNEL', None),
'director1' : os.environ.get('SL_BOT_DIRECTOR1', None),
'director2' : os.environ.get('SL_BOT_DIRECTOR2', None)
}
# Enable judging tab
JUDGING_ENABLED = True

# Can Hackers start a request on the hardware lab?
# HACKERS_CAN_REQUEST = False

Expand Down
8 changes: 8 additions & 0 deletions app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,14 @@
'teams',
'stats',
'storages',
'meals',
'judging',
'offer',
]

if BAGGAGE_ENABLED:
INSTALLED_APPS.append('baggage')

if REIMBURSEMENT_ENABLED:
INSTALLED_APPS.append('reimbursement')

Expand Down Expand Up @@ -266,3 +272,5 @@
MAX_VOTES = 10

MAX_VOTES_TO_APP = 50

MEALS_TOKEN = os.environ.get('MEALS_TOKEN', None)
21 changes: 20 additions & 1 deletion app/slack.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import requests
from django.conf import settings
from slackclient import SlackClient


class SlackInvitationException(BaseException):
Expand All @@ -17,7 +18,7 @@ def send_slack_invite(email, active=True):

if not token or not team:
raise SlackInvitationException(
"Not configured slack, team = %s and token = %s" % (team, token))
'Not configured slack, team = %s and token = %s' % (team, token))

r = requests.post(BASE_URL.format(team), data={
'email': email,
Expand All @@ -29,3 +30,21 @@ def send_slack_invite(email, active=True):
return True
else:
raise SlackInvitationException(response_object['error'])


def send_slack_message(user_email, content_message):
botid = settings.SLACK_BOT.get('id', None)
token = settings.SLACK_BOT.get('token', None)

if not token:
print('[ERROR] Slack bot not configured.')
else:
sc = SlackClient(token)
user = sc.api_call('users.lookupByEmail', email=user_email)
if user['ok']:
user_id = user['user']['id']
message = sc.api_call('chat.postMessage', channel=user_id, text=content_message, as_user=botid)
if not message['ok']:
print('[ERROR] Couldn\'t send Slack message.')
else:
print('[ERROR] Couldn\'t get Slack user information.')
Loading

0 comments on commit 1363b65

Please sign in to comment.