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

Rishabh/frontend refactor - added background, changed main name/color scheme, and more #162

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
95a9615
Merge pull request #42 from gotechnica/master
chris-sul Feb 3, 2020
58351a1
Adding docker build for frontend
chris-sul Feb 17, 2020
30636ff
Adding mongodb local development config example url
chris-sul Feb 17, 2020
bf3197c
correct number of sponsors is displayed in Admin page
Maosef Feb 18, 2020
c1712b0
Fixing docker config
chris-sul Feb 24, 2020
c58319c
Merge pull request #50 from bitcamp/dockerize_frontend
chris-sul Feb 24, 2020
43936b9
Updated Font-Awesome to v5
Sylean Feb 25, 2020
cf0c163
Remove testing log statment
chris-sul Mar 2, 2020
fba5a95
Merge pull request #52 from bitcamp/sponsor_count
chris-sul Mar 2, 2020
1df7350
Merge remote-tracking branch 'origin/master' into fontawesome-changes
chris-sul Mar 2, 2020
901154f
Merge pull request #53 from bitcamp/fontawesome-changes
chris-sul Mar 2, 2020
ca16670
Add github actions for pytest and style checking
chris-sul Mar 2, 2020
2ffe285
Fixing style errors
chris-sul Mar 3, 2020
866f584
Fixing CI config
chris-sul Mar 3, 2020
c7e89dc
Merge pull request #55 from bitcamp/python_style
chris-sul Mar 3, 2020
a111106
Adding status badge
chris-sul Mar 3, 2020
248da03
Convert several components to React Hooks syntax (#57)
eveninglily Mar 19, 2020
a67b43e
Update requirements.txt
eveninglily Apr 30, 2020
35dd3a2
Big Refactoring (#60)
eveninglily Apr 30, 2020
38bc09d
More hooks rewriting
eveninglily May 13, 2020
ddb12db
More refacotoring, linting, and docs
eveninglily Jun 8, 2020
aed7d3b
modernize expo / M1 support
Sylean Feb 1, 2022
f1f73cd
Changed lot of frontend for expo app
Mar 15, 2022
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
28 changes: 28 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Python Testing

on: [push]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox
- name: flake8
run: |
tox -e flake8
- name: pytest
run: |
tox -e py36
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ api/.mypy_cache/
.pytest_cache
pyvenv.cfg
.mypy_cache/
.tox/
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Hackathon Expo App

![Python Testing](https://github.com/bitcamp/hackathon-expo-app/workflows/Python%20Testing/badge.svg)

![Technica Expo Site](img/MainExpoPage.png)

A beautiful and intuitive web app to display hackathon projects for expo
Expand Down
5 changes: 3 additions & 2 deletions api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
From python:3.7
FROM python:3.6

ADD . /app

WORKDIR /app

RUN pip install -r requirements.txt
COPY requirements.txt /tmp/
RUN pip install --requirement /tmp/requirements.txt
RUN pip install gunicorn

EXPOSE 8000
30 changes: 23 additions & 7 deletions api/config.ex.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
# Config file. Rename as config.py and fill in keys/variables
MONGO_DBNAME = 'your-db-name-here' # e.g. 'expo-app'
MONGO_HOST = 'uri-to-connect-to-your-db-including-username-and-password' # e.g. 'mongodb://<dbuser>:<dbpassword>@ds261460.mlab.com:61460/expo-app' (if using mLab)
ADMIN_ACCESS_CODE = 'super-secret-admin-access-code-here' # Used to log into Godmode dashboard
SECRET_KEY = 'some-super-secret-string-used-for-flask-sessions' # A long string of random characters

EXPO_LENGTH = 60 # Total length of the expo (in minutes). Used for computing time per table for sponsors.
MONGO_DBNAME = 'your-db-name-here'
# e.g. 'expo-app'
MONGO_HOST = 'uri-to-connect-to-your-db-including-username-and-password'
# e.g. 'mongodb://<dbuser>:<dbpassword>@ds261460.mlab.com:61460/expo-app'
# (if using mLab) or
# 'mongodb://admin:password@db:27017/expo-testing?authSource=admin'
# for local development

# If you aren't allowing this option for hackers, replace the string with the python None variable
CUSTOM_DEVPOST_STAY_AT_TABLE_QUESTION = 'Exact string of the question configured in Devpost for checking which table a hack is currently at (if it must stay at that current table for expo).'
ADMIN_ACCESS_CODE = 'super-secret-admin-access-code-here'
# Used to log into Godmode dashboard
SECRET_KEY = 'some-super-secret-string-used-for-flask-sessions'
# A long string of random characters

EXPO_LENGTH = 60
# Total length of the expo (in minutes).
# Used for computing time per table for sponsors.

# If you aren't allowing this option for hackers,
# replace the string with the python None variable
CUSTOM_DEVPOST_STAY_AT_TABLE_QUESTION = ('Exact string of the question '
'configured in Devpost for checking '
'which table a hack is currently at '
'(if it must stay at that current '
'table for expo).')
13 changes: 7 additions & 6 deletions api/devpost_scraper.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
from bs4 import BeautifulSoup
from functools import reduce
import re
import urllib.request as ur
from typing import List, Tuple


def get_challenges(link: str) -> List[Tuple[str, str, int]]:
"""Given a devpost url, returns a list of companies and their challenges"""
sock = ur.urlopen(link)
soup = BeautifulSoup(sock,"html.parser")
soup = BeautifulSoup(sock, "html.parser")

prizes = soup.find("article",{"id":"prizes"}).find("ul").findAll("li")[1:]
prizes = list(map(lambda x: x.find("h6").text.strip(),prizes))
prizes = soup.find("article",
{"id": "prizes"}).find_all("div", {"class": "prize"})
prizes = list(map(lambda x: x.find("h6").text.strip(), prizes))
prizes = [i for i in prizes if "-" in i]

for i in range(len(prizes)):
Expand All @@ -19,8 +20,8 @@ def get_challenges(link: str) -> List[Tuple[str, str, int]]:
name = "-".join(description.split("-")[:-1]).strip()
company = description.split("\n")[0].split("-")[-1].strip()
num = 1
if re.search("\(\d+\)",description):
if re.search("\(\d+\)", description): # noqa
num = int(description.split("(")[-1].strip(")"))
prizes[i] = (name,company,num)
prizes[i] = (name, company, num)

return prizes
10 changes: 7 additions & 3 deletions api/loggingAnalytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,20 @@
file_handler.setLevel(logging.DEBUG)

# creating formatter
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
formatter = logging.Formatter(
'%(asctime)s - %(name)s - %(levelname)s - %(message)s')

# add formatter
file_handler.setFormatter(formatter)

# add handler
logger.addHandler(file_handler)

## Public endpoint logging
###
# Public endpoint logging
###


def logged_message(message: str) -> None:
logger.info(message)
return
return
6 changes: 2 additions & 4 deletions api/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
bs4==0.0.1
config==0.5.1
certifi==2018.8.24
chardet==3.0.4
click==6.7
Flask==1.0.2
Flask-Cors==3.0.6
Flask-PyMongo==0.5.2
get==1.0.3
idna==2.7
itsdangerous==0.24
Jinja2==2.10
logger==1.4
MarkupSafe==1.0
post==1.0.2
MarkupSafe==1.1.1
public==1.0.3
pymongo==3.6.1
query-string==1.0.2
Expand All @@ -21,4 +20,3 @@ urllib3==1.24.2
Werkzeug==0.15.3
mypy==0.720
mypy-extensions==0.4.1
pytest==5.2.0
10 changes: 4 additions & 6 deletions api/scripts/clear_db.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import csv
import re
import requests
import json
import helpers


def delete_project() -> None:
s = helpers.login()

Expand All @@ -21,12 +18,13 @@ def delete_all_projects() -> None:
s = helpers.login()

url = "https://expo-api.gotechnica.org/api/projects/deleteAll"
r = s.delete(url)
s.delete(url)


def main() -> None:
#delete_project()
# delete_project()
delete_all_projects()


if __name__ == "__main__":
main()
6 changes: 2 additions & 4 deletions api/scripts/get_codes.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
# Gets sponsor access codes

import re
import requests
import json
import helpers


def get_access_codes() -> None:
s = helpers.login()

Expand All @@ -20,5 +17,6 @@ def get_access_codes() -> None:
for c in cs:
print(c)


if __name__ == "__main__":
get_access_codes()
4 changes: 2 additions & 2 deletions api/scripts/helpers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import re
from requests import session, sessions
import json


def login() -> sessions.Session:
password = input("Password: ")
Expand All @@ -16,6 +15,7 @@ def login() -> sessions.Session:

return s


# helper method for printing stuff
def pretty_print_POST(req) -> None:
print('{}\n{}\n{}\n\n{}'.format(
Expand Down
11 changes: 6 additions & 5 deletions api/scripts/manual_assign.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import csv
import re
import requests
import json
import helpers


Expand All @@ -22,7 +20,7 @@ def available_tables() -> None:
all_tables = list(map(lambda x: number_to_table(x), list(range(1, 391))))
r = requests.get("https://expo-api.gotechnica.org/api/projects")

taken = re.findall('\"table_number\": \"(\w\d+)\"', r.text)
taken = re.findall('\"table_number\": \"(\w\d+)\"', r.text) # noqa
taken.sort()
open_tables = list(set(all_tables) - set(taken))
open_tables.sort()
Expand All @@ -31,7 +29,10 @@ def available_tables() -> None:
print(open_tables)


def add_project(table_number: int, project_url: str, project_name: str, challenges) -> None:
def add_project(table_number: int,
project_url: str,
project_name: str,
challenges) -> None:
s = helpers.login()
url = "https://expo-api.gotechnica.org/api/projects/add"
info = {
Expand All @@ -41,7 +42,7 @@ def add_project(table_number: int, project_url: str, project_name: str, challeng
'challenges': challenges,
'challenges_won': ""
}
r = s.post(url, json=info)
s.post(url, json=info)


def main() -> None:
Expand Down
22 changes: 12 additions & 10 deletions api/seed_db.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import csv
import json
import re
import requests
import time
from typing import Dict, List

"""
Expand Down Expand Up @@ -90,7 +88,7 @@ def check_if_needs_to_stay(response: str):
Any found regular expression matches from the arg.

"""
return re.search('([a-zA-Z]*\d+)', response)
return re.search('([a-zA-Z]*\d+)', response) # noqa


def format_challenges(challenges) -> List[Dict[any, any]]:
Expand All @@ -104,11 +102,12 @@ def format_challenges(challenges) -> List[Dict[any, any]]:
challenges: str of company challenge titles

Returns:
list of dicts with 'company', 'challenge_name', and if it has been 'won'
list of dicts with 'company', 'challenge_name',
and if it has been 'won'

"""
challenges_list = []
if challenges is not "":
if challenges:
challenges = challenges.split(',')
for challenge in challenges:
# TODO: possibly look into creating a hash from companies DB
Expand Down Expand Up @@ -139,6 +138,7 @@ def delete_projects():
# print("size of moving: ", len(moving))
# print("size of not moving: ", len(not_moving))


def parse_csv_internal(reader, not_moving_question=None):
"""Parses a CSV exported from DevPort and seperates hackers based on if
their hack needs to be stationary (i.e. can't move from table) or not.
Expand All @@ -149,14 +149,15 @@ def parse_csv_internal(reader, not_moving_question=None):

Args:
reader: CSV object
not_moving_question: str question to determine hackers' project mobility
not_moving_question: str question to determine hackers'
project mobility

Returns:
tuple (moving, not_moving) of dicts mapping project names -> Project()
objects.

"""
#already_stored = already_in_db()
# already_stored = already_in_db()
for row in reader:
project_name = row["Submission Title"].strip()
project_url = row["Submission Url"].strip()
Expand All @@ -177,11 +178,12 @@ def parse_csv_internal(reader, not_moving_question=None):

if needs_to_stay is not None:
not_moving[project_name] = Project(project_url, challenges)
assignments[table_to_number(needs_to_stay.group(0))] = project_name + " | "
assignments[table_to_number(needs_to_stay.group(0))] = \
project_name + " | "
not_moving[project_name].table_number = needs_to_stay.group(0)
else:
moving[project_name] = Project(project_url, challenges)

return moving, not_moving


Expand Down Expand Up @@ -224,7 +226,7 @@ def bulk_add_projects_local(projects) -> None:
packet = {
'projects': project_data
}
r = requests.post(url, json=packet)
requests.post(url, json=packet)


def main() -> None:
Expand Down
Loading