-
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.
Merge branch 'main' of https://github.com/appKom/online-opptak into p…
…eriod-card-loading
- Loading branch information
Showing
61 changed files
with
1,500 additions
and
3,572 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,39 @@ | ||
import { owCommitteeType } from "../lib/types/types"; | ||
|
||
interface CommitteeAboutCardProps { | ||
committee: owCommitteeType; | ||
hasPeriod: boolean; | ||
} | ||
|
||
const CommitteeAboutCard = ({ | ||
committee, | ||
hasPeriod, | ||
}: CommitteeAboutCardProps) => { | ||
const { image, name_long, name_short, email, application_description } = | ||
committee; | ||
|
||
return ( | ||
<div> | ||
<img | ||
src={image?.xs || "/Online_svart_o.svg"} | ||
alt={name_long} | ||
className="w-16 h-16 p-1 mb-2 bg-white rounded-full" | ||
/> | ||
|
||
<div className="flex items-center gap-2"> | ||
<h3 className="text-xl font-bold dark:text-white"> | ||
{name_long} {name_long !== name_short && `(${name_short})`} | ||
</h3> | ||
{hasPeriod && ( | ||
<span className="bg-green-100 text-green-800 text-xs font-medium me-2 px-2.5 py-0.5 rounded-full dark:bg-green-900 dark:text-green-300">Har opptak!</span> | ||
)} | ||
</div> | ||
<p className="mb-2 text-sm text-gray-500 dark:text-gray-400">{email}</p> | ||
<p className="text-gray-500 whitespace-pre-wrap dark:text-gray-400"> | ||
{application_description || "Ingen opptaksbeskrivelse"} | ||
</p> | ||
</div> | ||
); | ||
}; | ||
|
||
export default CommitteeAboutCard; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import React from "react"; | ||
|
||
const ImportantNote = ({ | ||
prefix, | ||
text, | ||
isLoading, | ||
}: { | ||
prefix: string; | ||
text: string | React.ReactNode; | ||
isLoading?: boolean; | ||
}) => { | ||
return ( | ||
<div className="flex items-center max-w-full p-4 mx-5 mb-5 text-sm text-yellow-500 rounded-md dark:text-online-orange bg-yellow-50 dark:bg-gray-800"> | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
viewBox="0 0 20 20" | ||
fill="currentColor" | ||
className="flex-shrink-0 w-5 h-5 mr-3" | ||
> | ||
<path | ||
fillRule="evenodd" | ||
d="M8.485 2.495c.673-1.167 2.357-1.167 3.03 0l6.28 10.875c.673 1.167-.17 2.625-1.516 2.625H3.72c-1.347 0-2.189-1.458-1.515-2.625L8.485 2.495zM10 5a.75.75 0 01.75.75v3.5a.75.75 0 01-1.5 0v-3.5A.75.75 0 0110 5zm0 9a1 1 0 100-2 1 1 0 000 2z" | ||
clipRule="evenodd" | ||
/> | ||
</svg> | ||
{isLoading ? ( | ||
<div className="h-2.5 bg-gray-200 rounded-full dark:bg-gray-700 w-48"></div> | ||
) : ( | ||
<div> | ||
<b className="mr-2">{prefix}</b> | ||
{text} | ||
</div> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default ImportantNote; |
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.