Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
58 changes: 37 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,39 @@
## Important things to know before developing locally or in C9
## Requirements
- Python2.7
- linux, unix, mac, windows(with attachments), Ubuntu
- virtualenv
- mysql and python mysql-db

- You will notice a bunch of sqlite related code, but we are no longer using sqlite
- You will need to have mysql and python mysql-db

# c9 Installation Guide #
## Setup
1. In your working environment, clone the URCPP Repo:
- `https://github.com/BCStudentSoftwareDevTeam/urcpp` as of 02/10/2022
3. Pull the most recent changes
4. Run `source setup.sh`

1. Create a work space in c9 with the python template and the github ssh url.
2. run `git pull` to ensure latest changes are pulled.
3. run `source setup.sh` to execute setup script.
4. run `phpmyadmin-ctl install` to run the phpmyadmin client.
5. navigate to the phpmyadmin interface
6. create a database named `urcpp_flask_v2`
7. add a user named `urcpp-flask` with password `DanforthLabor123!` and check `grant all permissions on database urcpp_flask_v2`
- See instructions [here](https://docs.google.com/document/d/1K2Ex8xsa65SwvCG3UdZ9bL-hLey9rTguOA9kfbENtwY/edit?usp=sharing) for more aid
8. comment out lines 20-27 in `api/__init__.py`
9. create a file `api/secret_key` with alphanumeric characters in the file
9. run `python recreate_static`
10. run `python recreate_dynamic`
11. comment lines 20-27 back in
12. run `python api.py`
13. if application does not load, comment out lines 80-83 in 'urcpp-flask/api/everything.py'
14. to initialize mysql, run 'mysql-ctl install' and answer 'Y'
## Create database with Phpmyadmin

5. Go to your Phpmyadmin interface and log in with your credentials
- Located here: `http://0.0.0.0/phpmyadmin/`
Make sure to replace 0.0.0.0 with your server's IP address
6. Create a new database named `urcpp_flask_v2`
- If a database of that name already exists, drop it and create it again
7. Create a user named `urcpp-flask` with password `DanforthLabor123!`
8. Grant all permissions on the database `urcpp_flask_v2` to `urcpp-flask`
Continue to step 14.

## Create database with MySQL Workbench and Terminal

9. In your terminal use the command `mysql -u root -p`. You will be prompted to enter your password
10. To create the database: `CREATE DATABASE urcpp_flask_v2;` (Make sure you include the ;)
11. To create a user named `urcpp-flask` with password `DanforthLabor123!`: `CREATE USER 'urcpp-flask'@localhost IDENTIFIED BY 'DanforthLabor123!'; `
12. To Grant all permissions on the database `urcpp_flask_v2` to `urcpp-flask`: ` GRANT ALL PRIVILEGES ON `urcpp_flask_v2` . * TO 'urcpp-flask'@localhost; `
13. To make sure permissions take effect: ` flush privileges; `

## Continue from here again
14. Create a file named `secret_key` in the `api` folder
- `secret_key` MUST contain some alphanumeric characters. Anything will work including `AnythignWillWork`
15. Comment out lines 20-27 in `api/__init__.py`
16. Run `python recreate_static.py`
17. Run `python recreate_dynamic.py`
18. Comment lines 20-27 in `api/__init__.py` back in
19. Run `python api.py`
4 changes: 2 additions & 2 deletions api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@



# Form pages
#Form pages
import pages.create
import pages.people
import pages.history
Expand Down Expand Up @@ -44,4 +44,4 @@
import chair.manageCommittee
import chair.email_accepted

import flaskLogin
import flaskLogin
16 changes: 8 additions & 8 deletions api/chair/awardLetters.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def awardLetters ():
currentCycle = getCurrentParameters()
faculty = getFacultyWithAcceptedProjects(currentCycle.year)
funding = {}

if faculty is not None:
for entry in faculty:
bID = entry.pID.budgetID
Expand All @@ -40,7 +40,7 @@ def awardLetters_save ():
# we need the current year to get current faculty with projects
template, created = EmailTemplates.get_or_create(eID = 1)
template.Body = request.form['body']
template.Subject = request.form['subject']
template.Subject = request.form['subject']
template.save()
return jsonify({"success": True})

Expand All @@ -55,7 +55,7 @@ def awardLetters_get ():
body = template.Body
subject = template.Subject
return jsonify({"body": body, "subject":subject})

@app.route("/chair/awardLetters/send/<username>/<pID>", methods = ["GET"])
@login_required
def awardLetters_generate(username,pID):
Expand All @@ -73,7 +73,7 @@ def awardLetters_generate(username,pID):
start = str(project.startDate.strftime("%B %d, %Y"))
end = str(project.endDate.strftime("%B %d, %Y"))
stipend = str(project.budgetID.facultyStipend)

# Replace all placeholder text
body = body.replace("@@Funding@@",funding)
body = body.replace("@@ProjectTitle@@",project_title)
Expand All @@ -96,7 +96,7 @@ def accept_letters_get(pID):
if not g.user.isCommitteeMember:
abort(403)
# All of our queries

project = Projects.get(Projects.pID == pID)
# we need the current year to get current faculty with projects
template = EmailTemplates.get(EmailTemplates.eID == 1)
Expand All @@ -108,13 +108,13 @@ def accept_letters_get(pID):
start = str(project.startDate.strftime("%B %d, %Y"))
end = str(project.endDate.strftime("%B %d, %Y"))
stipend = str(project.budgetID.facultyStipend)

# Replace all placeholder text
body = body.replace("@@Funding@@",funding)
body = body.replace("@@ProjectTitle@@",project_title)
body = body.replace("@@Students@@",student_count)
body = body.replace("@@Start Date@@",start)
body = body.replace("@@End Date@@",end)
body = body.replace("@@Stipend@@",stipend)
return jsonify({"body": body, "subject":subject})

return jsonify({"body": body, "subject":subject})
19 changes: 9 additions & 10 deletions api/chair/setParameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,25 @@ def setParameters_GET ():
appOpenDate = openDate,
appCloseDate =closeDate,
mileageRate = data['mileageRate'],
laborRate = data['laborRate'])

laborRate = data['laborRate'],
stipend = data['stipend'])

parameters.save()

flash('New application year succesfully created')
return redirect(url_for('setParameters_GET', username = g.user.username))

parameters = getCurrentParameters()
parameters_list = Parameters.select().order_by(-Parameters.year)
return render_template ("chair/setParameters.html",

return render_template ("chair/setParameters.html",
username = g.user.username,
ldap = g.user,
params = parameters,
parameters_list = parameters_list,
cfg = cfg,
)

@app.route("/delete/parameters/<pID>", methods=['GET'])
@login_required
def deleteParameters(pID):
Expand All @@ -45,9 +46,7 @@ def deleteParameters(pID):
try:
parameters = Parameters.get(Parameters.pID == pID)
parameters.delete_instance()

except Parameters.DoesNotExist:
flash('Parameters not found')
return redirect(redirect_url())


2 changes: 1 addition & 1 deletion api/everything.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def teardown_request(exception):
dbD = getattr(g, 'dbDynamic', None)
if (dbS is not None) and (not dbS.is_closed()):
dbS.close()
if (dbD is not None) and (not dbD.is_closed()):
if (dbD is not None) and (not dbD):
dbD.close()

@login_manager.user_loader
Expand Down
27 changes: 14 additions & 13 deletions api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Meta:

# To see the databases, do this:
# sqlite_web -p $PORT -H $IP -x data/test.sqlite

######################################################
# STATIC MODELS
######################################################
Expand All @@ -35,30 +35,30 @@ class LDAPFaculty (DynamicModel):
firstname = TextField()
isChair = BooleanField(default=False)
isCommitteeMember = BooleanField(default=False)

def is_active(self):
"""All user will be active"""
return True


def get_id(self):
return str(self.fID)

def is_authenticated(self):
"""Return True if the user is authenticated"""
return True

def is_anonymous(self):
return False

def __repr__(self):
return '{0} {1}'.format(self.firstname, self.lastname)
class LDAPStudents (DynamicModel):
username = PrimaryKeyField()
bnumber = TextField()
lastname = TextField()
firstname = TextField()

class Programs (DynamicModel):
pID = PrimaryKeyField()
name = TextField()
Expand All @@ -82,13 +82,13 @@ class Budget (DynamicModel):
materialsDesc = TextField(default = "")
other = IntegerField(null = True)
otherDesc = TextField(default = "")

class PreSurvey (DynamicModel):
psID = PrimaryKeyField()

class PostSurvey (DynamicModel):
psID = PrimaryKeyField()


class Parameters (DynamicModel):
pID = PrimaryKeyField()
Expand All @@ -98,6 +98,7 @@ class Parameters (DynamicModel):
mileageRate = FloatField() # Or Double?
laborRate = FloatField() # Or Double?
isCurrentParameter = BooleanField(default=False)
stipend = FloatField()

class Projects (DynamicModel):
pID = PrimaryKeyField()
Expand Down Expand Up @@ -134,14 +135,14 @@ class URCPPFaculty (DynamicModel):
fID = PrimaryKeyField()
pID = ForeignKeyField(Projects, db_column="pid_id", related_name = "project")
username = ForeignKeyField(LDAPFaculty, to_field = "username")
# We will always name these ourselves, and
# We will always name these ourselves, and
# choose where they go. It is in our config[] YAML.
# Something like...
# /year/projid/username.pdf
# vitae = BlobField()
yearsFunded = TextField( default = "" )
relatedFunding = TextField( default = "" )
programID = ForeignKeyField(Programs, default = 0)
programID = ForeignKeyField(Programs, default = 0)

class Collaborators (DynamicModel):
cID = PrimaryKeyField()
Expand All @@ -168,7 +169,7 @@ class Voting (DynamicModel):
budget = FloatField(null = True)
timeline = FloatField(null = True)
comments = TextField(null = True)

class EmailTemplates (DynamicModel):
eID = PrimaryKeyField()
Body = TextField(null = True)
Expand Down
12 changes: 6 additions & 6 deletions api/static/js/pages/setParameters.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/* global $, swal */
/* global $, swal */
$(function() {
$("#applicationOpenDate").datepicker({
dateFormat: "yy-mm-dd"
});

$("#applicationCloseDate").datepicker({
dateFormat: "yy-mm-dd"
});
});

$('.selectpicker').selectpicker({
});

function change_check_color(parameters_id){
$(".isCurrentParameter").addClass("disabled");

$("#set_current_parameters-"+parameters_id).removeClass("disabled")
}

Expand All @@ -41,7 +41,7 @@ function(isConfirm){
});

};

function warnBeforeRedirect(url) {
swal({
title: "Are you sure?",
Expand All @@ -62,7 +62,7 @@ function(isConfirm){
}
});
}

$("#delete_parameters").click(function(e) {
e.preventDefault();
var linkURL = $(this).attr("href");
Expand Down
Loading