-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
49 changed files
with
1,232 additions
and
633 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
MONGODB_URI=#url to mongodb database | ||
DB_NAME=#name of db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
from pymongo import MongoClient | ||
from dotenv import load_dotenv | ||
from datetime import datetime, timezone | ||
import os | ||
import certifi | ||
|
||
def main(): | ||
periods = fetch_periods() | ||
|
||
#Sjekker om perioden er etter søknadstiden og før intervjuslutt og hasSentInterviewtimes er false, og returnerer søkere og komitétider dersom det er tilfelle | ||
for period in periods: | ||
periodId = str(period["_id"]) | ||
interview_end = datetime.fromisoformat(period["interviewPeriod"]["end"].replace("Z", "+00:00")) | ||
application_end = datetime.fromisoformat(period["applicationPeriod"]["end"].replace("Z", "+00:00")) | ||
|
||
|
||
now = datetime.now(timezone.utc) | ||
|
||
if application_end > now and period["hasSentInterviewTimes"] == False and interview_end < now: | ||
applicants = fetch_applicants(periodId) | ||
committee_times = fetch_committee_times(periodId) | ||
print(applicants) | ||
print(committee_times) | ||
|
||
return applicants, committee_times | ||
|
||
|
||
def connect_to_db(collection_name): | ||
load_dotenv() | ||
|
||
mongo_uri = os.getenv("MONGODB_URI") | ||
db_name = os.getenv("DB_NAME") | ||
|
||
client = MongoClient(mongo_uri, tlsCAFile=certifi.where()) | ||
|
||
db = client[db_name] # type: ignore | ||
|
||
collection = db[collection_name] | ||
|
||
return collection, client | ||
|
||
def fetch_periods(): | ||
collection, client = connect_to_db("period") | ||
|
||
periods = collection.find() | ||
|
||
periods = list(periods) | ||
|
||
client.close() | ||
|
||
return periods | ||
|
||
def fetch_applicants(periodId): | ||
collection, client = connect_to_db("applicant") | ||
|
||
applicants = collection.find({"periodId": periodId}) | ||
|
||
applicants = list(applicants) | ||
|
||
client.close() | ||
|
||
return applicants | ||
|
||
def fetch_committee_times(periodId): | ||
collection, client = connect_to_db("committee") | ||
|
||
committee_times = collection.find({"periodId": periodId}) | ||
|
||
committee_times = list(committee_times) | ||
|
||
client.close() | ||
|
||
return committee_times | ||
|
||
if __name__ == "__main__": | ||
main() |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import Image from "next/image"; | ||
import { useTheme } from "../lib/hooks/useTheme"; | ||
|
||
const ErrorPage = () => { | ||
const theme = useTheme(); | ||
|
||
const onlineLogoSrc = | ||
theme === "dark" ? "/Online_hvit.svg" : "/Online_bla.svg"; | ||
|
||
return ( | ||
<div className="flex flex-col items-center justify-center h-full gap-10 bg-white dark:bg-gray-900"> | ||
<Image | ||
src={onlineLogoSrc} | ||
width={300} | ||
height={100} | ||
alt="Online logo" | ||
/> | ||
<div className="text-xl text-black dark:text-white">Det har skjedd en feil :(</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ErrorPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
export const PeriodSkeleton = () => { | ||
return ( | ||
<div className="w-full max-w-md p-4 border border-gray-200 rounded shadow animate-pulse md:p-6 dark:border-gray-700 "> | ||
<div className="h-2.5 bg-gray-200 rounded-full dark:bg-gray-700 w-48 mb-4"></div> | ||
<div className="h-2 bg-gray-200 rounded-full dark:bg-gray-700 mb-2.5"></div> | ||
<div className="h-2 bg-gray-200 rounded-full dark:bg-gray-700 mb-2.5"></div> | ||
<div className="h-2 bg-gray-200 rounded-full dark:bg-gray-700"></div> | ||
</div> | ||
); | ||
}; | ||
|
||
export const PeriodSkeletonPage = () => { | ||
return ( | ||
<div className="flex flex-col justify-between overflow-x-hidden text-online-darkBlue dark:text-white"> | ||
<div className="flex flex-col items-center justify-center gap-5 px-5 my-10"> | ||
<div className="flex flex-col gap-10"> | ||
<h3 className="text-4xl font-bold tracking-tight text-center dark:text-white"> | ||
Nåværende opptaksperioder | ||
</h3> | ||
<div className="flex flex-col items-center max-w-full gap-5"> | ||
<PeriodSkeleton /> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.