diff --git a/backend/seed_data/src/seed.rs b/backend/seed_data/src/seed.rs index f542faa2..a7d4b395 100644 --- a/backend/seed_data/src/seed.rs +++ b/backend/seed_data/src/seed.rs @@ -133,7 +133,9 @@ pub fn seed() { .expect(&format!("Failed to insert org {}.", org.name)); } - assert!(Organisation::get_all(&connection).len() == 2); + let x = Organisation::get_all(&connection); + println!("{:?}", x); + assert!(x.len() == 2); println!("... Added {} organizations\n", orgs.len()); // make giuliana the admin of csesoc diff --git a/backend/server/src/database/models.rs b/backend/server/src/database/models.rs index d4236081..67faef39 100644 --- a/backend/server/src/database/models.rs +++ b/backend/server/src/database/models.rs @@ -152,7 +152,7 @@ impl NewUser { } } -#[derive(Queryable, Serialize, Deserialize)] +#[derive(Queryable, Serialize, Deserialize, Debug)] pub struct Organisation { pub id: i32, pub name: String, diff --git a/backend/server/src/src/database/schema.rs b/backend/server/src/src/database/schema.rs new file mode 100644 index 00000000..f138f6d2 --- /dev/null +++ b/backend/server/src/src/database/schema.rs @@ -0,0 +1,174 @@ +// @generated automatically by Diesel CLI. + +pub mod sql_types { + #[derive(diesel::sql_types::SqlType)] + #[diesel(postgres_type(name = "admin_level"))] + pub struct AdminLevel; + + #[derive(diesel::sql_types::SqlType)] + #[diesel(postgres_type(name = "application_status"))] + pub struct ApplicationStatus; + + #[derive(diesel::sql_types::SqlType)] + #[diesel(postgres_type(name = "user_gender"))] + pub struct UserGender; +} + +diesel::table! { + answers (id) { + id -> Int4, + application_id -> Int4, + question_id -> Int4, + description -> Text, + created_at -> Timestamp, + updated_at -> Timestamp, + } +} + +diesel::table! { + use diesel::sql_types::*; + use super::sql_types::ApplicationStatus; + + applications (id) { + id -> Int4, + user_id -> Int4, + role_id -> Int4, + status -> ApplicationStatus, + created_at -> Timestamp, + updated_at -> Timestamp, + private_status -> Nullable, + } +} + +diesel::table! { + campaigns (id) { + id -> Int4, + organisation_id -> Int4, + name -> Text, + cover_image -> Nullable, + description -> Text, + starts_at -> Timestamp, + ends_at -> Timestamp, + published -> Bool, + created_at -> Timestamp, + updated_at -> Timestamp, + } +} + +diesel::table! { + comments (id) { + id -> Int4, + application_id -> Int4, + commenter_user_id -> Int4, + description -> Text, + created_at -> Timestamp, + updated_at -> Timestamp, + } +} + +diesel::table! { + use diesel::sql_types::*; + use super::sql_types::AdminLevel; + + organisation_users (id) { + id -> Int4, + user_id -> Int4, + organisation_id -> Int4, + admin_level -> AdminLevel, + created_at -> Timestamp, + updated_at -> Timestamp, + } +} + +diesel::table! { + organisations (id) { + id -> Int4, + name -> Text, + logo -> Nullable, + created_at -> Timestamp, + updated_at -> Timestamp, + } +} + +diesel::table! { + questions (id) { + id -> Int4, + role_ids -> Array>, + title -> Text, + description -> Nullable, + max_bytes -> Int4, + required -> Bool, + created_at -> Timestamp, + updated_at -> Timestamp, + } +} + +diesel::table! { + ratings (id) { + id -> Int4, + application_id -> Int4, + rater_user_id -> Int4, + rating -> Int4, + created_at -> Timestamp, + updated_at -> Timestamp, + } +} + +diesel::table! { + roles (id) { + id -> Int4, + campaign_id -> Int4, + name -> Text, + description -> Nullable, + min_available -> Int4, + max_available -> Int4, + finalised -> Bool, + created_at -> Timestamp, + updated_at -> Timestamp, + } +} + +diesel::table! { + use diesel::sql_types::*; + use super::sql_types::UserGender; + + users (id) { + id -> Int4, + email -> Text, + zid -> Text, + display_name -> Text, + degree_name -> Text, + degree_starting_year -> Int4, + superuser -> Bool, + created_at -> Timestamp, + updated_at -> Timestamp, + gender -> UserGender, + pronouns -> Text, + } +} + +diesel::joinable!(answers -> applications (application_id)); +diesel::joinable!(answers -> questions (question_id)); +diesel::joinable!(applications -> roles (role_id)); +diesel::joinable!(applications -> users (user_id)); +diesel::joinable!(campaigns -> organisations (organisation_id)); +diesel::joinable!(comments -> applications (application_id)); +diesel::joinable!(comments -> users (commenter_user_id)); +diesel::joinable!(organisation_users -> organisations (organisation_id)); +diesel::joinable!(organisation_users -> users (user_id)); +diesel::joinable!(ratings -> applications (application_id)); +diesel::joinable!(ratings -> users (rater_user_id)); +diesel::joinable!(roles -> campaigns (campaign_id)); + +diesel::allow_tables_to_appear_in_same_query!( + answers, + applications, + campaigns, + comments, + organisation_users, + organisations, + questions, + ratings, + roles, + users, +); diff --git a/frontend/src/api/index.ts b/frontend/src/api/index.ts index 95b5cc40..b7841706 100644 --- a/frontend/src/api/index.ts +++ b/frontend/src/api/index.ts @@ -41,12 +41,14 @@ export const doSignup = async ({ zid, starting_year, gender, + pronouns, }: { name: string; degree_name: string; zid: string; starting_year: number; gender: UserGender; + pronouns: string; }) => API.request<{ token: string }>({ method: "POST", @@ -58,6 +60,7 @@ export const doSignup = async ({ degree_starting_year: starting_year, degree_name, gender, + pronouns, }, }); diff --git a/frontend/src/pages/signup/index.tsx b/frontend/src/pages/signup/index.tsx index c091cfa5..c7d99d53 100644 --- a/frontend/src/pages/signup/index.tsx +++ b/frontend/src/pages/signup/index.tsx @@ -23,6 +23,7 @@ type TFormData = { degree_name: string; starting_year: number; gender: UserGender; + pronouns: string; }; /* eslint-enable @typescript-eslint/naming-convention */ @@ -33,6 +34,7 @@ const Signup = () => { degree_name: "", starting_year: new Date().getFullYear(), gender: "Unspecified", + pronouns: "", }); const navigate = useNavigate(); @@ -132,6 +134,16 @@ const Signup = () => { + + + Pronouns + + setFormData({ ...formData, pronouns: e.target.value }) + } + /> +