Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
f45df29
RHApp Release (#778)
gunbux Jan 30, 2023
1336ded
[BE] AuthenticationAPI Account Registration Bug Fix (#789) (#791)
gunbux Feb 19, 2023
df35777
Update docker files
raffleshall Feb 20, 2023
4f23f61
Fixed typo
raffleshall Feb 20, 2023
5ac3c00
Bot infra
raffleshall Apr 17, 2023
377dc3e
Update docker-compose.yml
kwangyy May 19, 2023
fe7a9bb
Merge pull request #802 from rhdevs/kwangyy-patch-1
theman-oj10 May 21, 2023
2d5c1f5
Update docker-compose.yml
kwangyy May 21, 2023
a223832
Update docker-compose.yml
kwangyy May 21, 2023
9ffccb9
Opened ports up for Telegram bot
kwangyy May 22, 2023
748b20b
Updated requirements.txt for RHApp
kwangyy May 22, 2023
9e82c48
Merge branch 'main' into bot
gunbux May 22, 2023
49e1a0d
Merge pull request #803 from rhdevs/bot
kwangyy May 22, 2023
937cd89
Updated RH Announcement Bot
raffleshall May 22, 2023
d45667c
Updated bot docker compose
raffleshall May 22, 2023
2b9dfbd
Updated infra
raffleshall Jun 14, 2023
89a8a1d
Update action.ts
theman-oj10 Jul 27, 2023
fcbb39f
Merge pull request #805 from rhdevs/theman-oj10-DateTimeBug
kwangyy Jul 27, 2023
ff84681
updated prod-deploy.sh
raffleshall Aug 8, 2023
255df8b
edited prod-deploy.sh
raffleshall Aug 8, 2023
25581eb
edited prod-deploy.sh
raffleshall Aug 8, 2023
da74d84
changed directory
raffleshall Aug 8, 2023
e584b8a
i really need to start doing this right xd
raffleshall Aug 8, 2023
eeae278
one last time
raffleshall Aug 8, 2023
0f5eb62
Updates
raffleshall Aug 9, 2023
a5d0462
Deployment updates
raffleshall Aug 9, 2023
05bbac6
Bump bot
raffleshall Aug 9, 2023
1c78da4
fixed 24hr booking bug
LWS49 Sep 19, 2023
295ab0e
Merge pull request #806 from rhdevs/debug-24hr
kwangyy Sep 20, 2023
f857dc9
added new hall manager to list of admin accounts
gnimnix Jun 18, 2024
0f078c0
added missing comma
gnimnix Jun 18, 2024
c2fb9a7
Merge pull request #810 from rhdevs/gnimnix-patch-1
gnimnix Jun 18, 2024
5375775
fixed typo in username
gnimnix Jul 12, 2024
1b99c63
Merge pull request #811 from rhdevs/gnimnix-patch-1
gnimnix Jul 12, 2024
15d1ef7
Update rh_announcer_bot
gnimnix Aug 2, 2024
b48c0dc
use gmail smtp instead of outlook
farhan-navas Mar 12, 2025
4b3d16f
Merge pull request #812 from farhan-navas/main
farhan-navas Mar 12, 2025
0ea9d25
try to rectify errors to work with node 18
farhan-navas Mar 21, 2025
3b4c400
Merge branch 'main' of github.com:farhan-navas/rhapp
farhan-navas Mar 21, 2025
fee7a17
Merge pull request #813 from farhan-navas/main
farhan-navas Mar 21, 2025
1062202
set node version to 18.x
farhan-navas Mar 21, 2025
17a2e19
Merge branch 'main' of github.com:farhan-navas/rhapp
farhan-navas Mar 21, 2025
37fc30f
Merge pull request #814 from farhan-navas/main
farhan-navas Mar 21, 2025
9c802bd
rm yarn lock file
farhan-navas Mar 21, 2025
dce546e
Merge pull request #815 from farhan-navas/main
farhan-navas Mar 21, 2025
4ee290d
update peer deps and eslintrc
farhan-navas Mar 21, 2025
f9d028a
Merge pull request #816 from farhan-navas/main
farhan-navas Mar 21, 2025
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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@ letsencrypt

# log files
output.txt
dump
err
logs
out.logs

# secrets
secrets
config.monitoring
bot_creds.py

# dependencies
/node_modules
Expand Down
Binary file removed assets/.DS_Store
Binary file not shown.
6 changes: 3 additions & 3 deletions backend/Authentication/AuthenticationAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


def load_mail():
current_app.config['MAIL_SERVER'] = 'smtp.office365.com'
current_app.config['MAIL_SERVER'] = 'smtp.gmail.com'
current_app.config['MAIL_PORT'] = 587
# to test input your own NUS acc email
current_app.config['MAIL_USERNAME'] = os.environ['EMAIL_USER']
Expand Down Expand Up @@ -128,7 +128,7 @@ def register():
if telegramHandle.startswith('@'):
telegramHandle = telegramHandle[1:]

if db.User.find({'userID': userID}).count(): # entry exists
if db.User.count_documents({'userID': userID}): # entry exists
return jsonify({'message': 'User already exists'}), 401
# add to User table
# note: if the user data does not adhere to defined validation standards, an error will be thrown here
Expand All @@ -140,7 +140,7 @@ def register():
"bio": bio,
"block": block,
"telegramHandle": telegramHandle,
"profilePictureURI": "https://www.gravatar.com/avatar/00000000000000000000000000000000?d=identicon"
"imageKey": "default/profile_pic.png"
})
except Exception as e:
print(e)
Expand Down
124 changes: 123 additions & 1 deletion backend/FacilityBooking/FacilitiesAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

facilities_api = Blueprint("facilities", __name__)

# Used to convert CCA ID into CCA Name


# Used to convert CCA ID into CCA Name
def conversion(ccaID):
return str(db.CCA.find_one({"ccaID": ccaID})["ccaName"])

Expand All @@ -38,6 +38,58 @@ def all_facilities():
return make_response(response)


@ facilities_api.route('/available', methods=["GET"])
@ cross_origin(supports_credentials=True)
def available_facilities_within_time():
try:
all_facilities = list(db.Facilities.find({}, {"_id": 0}).sort("facilityID", 1))
startTime = int(request.args.get('startTime')) if request.args.get('startTime') else 0
endTime = int(request.args.get('endTime')) if request.args.get('endTime') else -1
if endTime <= startTime:
return {"err": "Invalid start and end time", "status": "failed"}, 400

condition = {
"$and": [
{
"startTime": {
"$lt": endTime
}
},
{
"endTime": {
"$gt": startTime
}
}
]
}

pipeline = [
{'$match':
condition
},
{'$lookup': {
'from': 'Facilities',
'localField': 'facilityID',
'foreignField': 'facilityID',
'as': 'facility'
}},
{'$unwind': {'path': '$facility', 'preserveNullAndEmptyArrays': True}},
{'$addFields': {
'facilityName': '$facility.facilityName',
'facilityLocation': '$facility.facilityLocation'
}},
{'$project': {'facilityID': 1, 'facilityName': 1, 'facilityLocation': 1, '_id': 0}},
]

occupied_facilities = list(db.Bookings.aggregate(pipeline))
available_facilities = list(filter(lambda fac: fac not in occupied_facilities, all_facilities))
response = {"available_facilities": available_facilities, "status": "success"}, 200
except Exception as e:
print(e)
return {"err": "An error has occurred", "status": "failed"}, 500
return make_response(response)


@ facilities_api.route('/facilities/<facilityID>', methods=["GET"])
@ cross_origin(supports_credentials=True)
def get_facility_name(facilityID):
Expand Down Expand Up @@ -248,6 +300,76 @@ def check_bookings(facilityID):
return make_response(response)


@ facilities_api.route('/bookings', methods=["GET"])
@ cross_origin(supports_credentials=True)
def check_bookings_within_time():
try:
startTime = int(request.args.get('startTime')) if request.args.get('startTime') else 0
endTime = int(request.args.get('endTime')) if request.args.get('endTime') else -1
if endTime <= startTime:
return {"err": "Invalid start and end time", "status": "failed"}, 400

condition = {
"$and": [
{
"startTime": {
"$lt": endTime
}
},
{
"endTime": {
"$gt": startTime
}
}
]
}

pipeline = [
{'$match':
condition
},
{'$lookup': {
'from': 'User',
'localField': 'userID',
'foreignField': 'userID',
'as': 'profile'
}},
{'$unwind': {'path': '$profile', 'preserveNullAndEmptyArrays': True}},
{'$addFields': {
'displayName': '$profile.displayName'
}},
{'$lookup': {
'from': 'CCA',
'localField': 'ccaID',
'foreignField': 'ccaID',
'as': 'cca'
}},
{'$unwind': {'path': '$cca', 'preserveNullAndEmptyArrays': True}},
{'$addFields': {
'ccaName': '$cca.ccaName'
}},
{'$lookup': {
'from': 'Facilities',
'localField': 'facilityID',
'foreignField': 'facilityID',
'as': 'facility'
}},
{'$unwind': {'path': '$facility', 'preserveNullAndEmptyArrays': True}},
{'$addFields': {
'facilityName': '$facility.facilityName'
}},
{'$project': {'profile': 0, 'cca': 0, 'facility': 0, '_id': 0}}
]

data = list(db.Bookings.aggregate(pipeline))
data.sort(key=lambda x: x.get('startTime'))
response = {"startTime": startTime, "endTime": endTime, "bookings_placed": data, "status": "success"}, 200
except Exception as e:
print(e)
return {"err": "An error has occurred", "status": "failed"}, 500
return make_response(response)


@ facilities_api.route('/bookings', methods=['POST'])
@ cross_origin(supports_credentials=True)
def add_booking():
Expand Down
2 changes: 1 addition & 1 deletion backend/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pymongo >= 3.11.2
flask >= 1.1.2
jinja2 == 3.0.3
jinja2 >= 3.0.3
werkzeug >= 2.0.3
dnspython >= 2.0.0
flask-cors >= 3.0.10
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ services:
expose:
- 8080
restart: on-failure
env_file:
- ./secrets/rhapp_env
networks:
- intranet
labels:
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ services:
expose:
- 8080
restart: on-failure
env_file:
- ./secrets/rhapp_env
networks:
- intranet
labels:
Expand Down
5 changes: 4 additions & 1 deletion frontend/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ module.exports = {
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
// e.g. "@typescript-eslint/explicit-function-return-type": "off",
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-explicit-any': 'off',

'prettier/prettier': [
'error',
// 'error',
'off',
{
endOfLine: 'auto',
},
Expand Down
Loading