Skip to content

Commit 61321d1

Browse files
committed
Merge branch 'development' into 104
2 parents f7a39b5 + 0ce54c1 commit 61321d1

File tree

11 files changed

+125
-51
lines changed

11 files changed

+125
-51
lines changed

Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# The first instruction is what image we want to base our container on
2+
# We Use an official Python runtime as a parent image
3+
FROM python:2.7
4+
5+
MAINTAINER Guillermo Ramos "[email protected]"
6+
7+
EXPOSE 8080
8+
9+
COPY ./requirements.txt /requirements.txt
10+
11+
WORKDIR /
12+
13+
RUN pip install -r requirements.txt
14+
15+
COPY . /
16+
ENTRYPOINT [ "python" ]
17+
18+
CMD [ "api.py" ]

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
- You will notice a bunch of sqlite related code, but we are no longer using sqlite
44
- You will need to have mysql and python mysql-db
5-
5+
66
# c9 Installation Guide #
77

88
1. Create a work space in c9 with the python template and the github ssh url.
@@ -21,3 +21,8 @@
2121
12. run `python api.py`
2222
13. if application does not load, comment out lines 80-83 in 'urcpp-flask/api/everything.py'
2323
14. to initialize mysql, run 'mysql-ctl install' and answer 'Y'
24+
25+
# Running on containers
26+
Full instructions are in [this document](https://docs.google.com/document/d/1YWG9-D0WaCMS9x9uLrxHSjmvakaJZhHY5Dy9JwfzFBs/edit?usp=sharing)
27+
28+
Site will be running on your localhost port 8080: http://localhost:8080

api.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/usr/bin/env python
12
import os
23
from api import app
34
from api.config import load_config
@@ -17,7 +18,7 @@
1718

1819
if os.getenv('PORT'):
1920
PORT = int(os.getenv('PORT'))
20-
PORT = 8081
21+
PORT = 8080
2122
else:
2223
PORT = 8080
2324

@@ -26,4 +27,5 @@
2627
#app.secret_key = skt['secret_key']
2728
app.tag = cfg['tag']
2829

29-
app.run(host = IP, port = PORT, debug = True, threaded = True)
30+
if __name__ == "__main__":
31+
app.run(host = IP, port = PORT, debug = True, threaded = True)

api/API/budget.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def getBudget (username):
1616
budgQ = (Budget.select()
1717
.where (Budget.bID == proj.budgetID)
1818
)
19-
app.logger.info("Looking for budget with query:\n\n" + budgQ + "\n\n")
19+
# app.logger.info("Looking for budget with query:\n\n" + budgQ + "\n\n")
2020

2121
if budgQ.exists():
2222
return budgQ.get()

api/API/parameters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ def getCurrentParameters():
55

66
paramsQ = (Parameters.select().where(Parameters.isCurrentParameter))
77

8-
app.logger.info("Looking for parameters with query:\n\n" + paramsQ + "\n\n")
8+
#app.logger.info("Looking for parameters with query:\n\n" + paramsQ + "\n\n")
99

1010
if paramsQ.exists():
1111
return paramsQ.get()

api/chair/setParameters.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def setParameters_GET ():
2121
parameters.mileageRate = data['mileageRate']
2222
parameters.laborRate = data['laborRate']
2323

24+
2425
parameters.save()
2526

2627
flash("Successfully saved" , "success")

api/everything.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
def authUser(env):
3737
envK = "eppn"
38-
38+
3939
#print("Huh?", app.config)
4040
#app.logger.info("Found remote user: " + env.get("HTTP_X_REMOTE_USER") + env.get("PHP_AUTH_USER"))
4141
if (envK in env):
@@ -79,15 +79,6 @@ def before_request():
7979
#g.dbDynamic = dynamicDB.connect()
8080
g.user = current_user
8181

82-
@app.teardown_request
83-
def teardown_request(exception):
84-
dbS = getattr(g, 'dbStatic', None)
85-
# dbD = getattr(g, 'dbDynamic', None)
86-
if (dbS is not None) and (not dbS.is_closed()):
87-
dbS.close()
88-
# if (dbD is not None) and (not dbD.is_closed()):
89-
# dbD.close()
90-
9182
@login_manager.user_loader
9283
def load_user(fID):
9384
return LDAPFaculty.get(LDAPFaculty.fID == fID)

api/models.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Meta:
2222

2323
# To see the databases, do this:
2424
# sqlite_web -p $PORT -H $IP -x data/test.sqlite
25-
25+
2626
######################################################
2727
# STATIC MODELS
2828
######################################################
@@ -35,30 +35,30 @@ class LDAPFaculty (DynamicModel):
3535
firstname = TextField()
3636
isChair = BooleanField(default=False)
3737
isCommitteeMember = BooleanField(default=False)
38-
38+
3939
def is_active(self):
4040
"""All user will be active"""
4141
return True
42-
43-
42+
43+
4444
def get_id(self):
4545
return str(self.fID)
46-
46+
4747
def is_authenticated(self):
4848
"""Return True if the user is authenticated"""
4949
return True
50-
50+
5151
def is_anonymous(self):
5252
return False
53-
53+
5454
def __repr__(self):
5555
return '{0} {1}'.format(self.firstname, self.lastname)
5656
class LDAPStudents (DynamicModel):
5757
username = PrimaryKeyField()
5858
bnumber = TextField()
5959
lastname = TextField()
6060
firstname = TextField()
61-
61+
6262
class Programs (DynamicModel):
6363
pID = PrimaryKeyField()
6464
name = TextField()
@@ -82,13 +82,13 @@ class Budget (DynamicModel):
8282
materialsDesc = TextField(default = "")
8383
other = IntegerField(null = True)
8484
otherDesc = TextField(default = "")
85-
85+
8686
class PreSurvey (DynamicModel):
8787
psID = PrimaryKeyField()
8888

8989
class PostSurvey (DynamicModel):
9090
psID = PrimaryKeyField()
91-
91+
9292

9393
class Parameters (DynamicModel):
9494
pID = PrimaryKeyField()
@@ -134,14 +134,14 @@ class URCPPFaculty (DynamicModel):
134134
fID = PrimaryKeyField()
135135
pID = ForeignKeyField(Projects, db_column="pid_id", related_name = "project")
136136
username = ForeignKeyField(LDAPFaculty, to_field = "username")
137-
# We will always name these ourselves, and
137+
# We will always name these ourselves, and
138138
# choose where they go. It is in our config[] YAML.
139139
# Something like...
140140
# /year/projid/username.pdf
141141
# vitae = BlobField()
142142
yearsFunded = TextField( default = "" )
143143
relatedFunding = TextField( default = "" )
144-
programID = ForeignKeyField(Programs, default = 0)
144+
programID = ForeignKeyField(Programs, default = 0)
145145

146146
class Collaborators (DynamicModel):
147147
cID = PrimaryKeyField()
@@ -168,7 +168,7 @@ class Voting (DynamicModel):
168168
budget = FloatField(null = True)
169169
timeline = FloatField(null = True)
170170
comments = TextField(null = True)
171-
171+
172172
class EmailTemplates (DynamicModel):
173173
eID = PrimaryKeyField()
174174
Body = TextField(null = True)

api/static/js/pages/done.js

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,26 @@
2222

2323
function withdraw(projectID) {
2424
swal({
25-
title: "Are you sure?",
26-
text: "All files will be deleted!",
27-
type: "warning",
28-
showCancelButton: true,
29-
confirmButtonColor: "#DD6B55",
30-
confirmButtonText: "Yes, delete it!",
31-
cancelButtonText: "No, cancel please!",
32-
closeOnConfirm: false,
33-
closeOnCancel: false
34-
},
35-
function(isConfirm){
36-
if (isConfirm) {
37-
var postValue = {};
38-
postValue[projectID] = 'Withdrawn';
39-
$.post("/committee/allProjects/updateStatus", postValue, function(result){
40-
});
41-
window.location.replace("/");
42-
} else {
43-
swal("Cancelled", "Your imaginary file is safe :)", "error");
44-
}
45-
});
25+
title: "Are you sure?",
26+
text: "All files will be deleted!",
27+
type: "warning",
28+
showCancelButton: true,
29+
confirmButtonColor: "#DD6B55",
30+
confirmButtonText: "Yes, delete it!",
31+
cancelButtonText: "No, cancel please!",
32+
closeOnConfirm: false,
33+
closeOnCancel: false
34+
},
35+
function(isConfirm){
36+
if (isConfirm) {
37+
var postValue = {};
38+
postValue[projectID] = 'Withdrawn';
39+
$.post("/committee/allProjects/updateStatus", postValue, function(result){
40+
window.location.replace("/");
41+
});
4642

47-
48-
};
43+
} else {
44+
swal("Cancelled", "Your imaginary file is safe :)", "error");
45+
}
46+
});
47+
};

docker-compose.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
version: "3.7"
2+
services:
3+
app:
4+
build: .
5+
links:
6+
- db
7+
ports:
8+
- "8080:8080"
9+
db:
10+
image: mysql:5.7
11+
ports:
12+
- "3306:3306"
13+
environment:
14+
MYSQL_DATABASE: 'urcpp_flask_v2'
15+
# So you don't have to use root, but you can if you like
16+
MYSQL_USER: 'urcpp-flask'
17+
# You can use whatever password you like
18+
MYSQL_PASSWORD: 'DanforthLabor123!'
19+
# Password for root access
20+
MYSQL_ROOT_PASSWORD: 'password'
21+
volumes:
22+
- ./docker/data/db:/var/lib/mysql

0 commit comments

Comments
 (0)