Skip to content

Commit

Permalink
SQL or hasura is erroring currently
Browse files Browse the repository at this point in the history
  • Loading branch information
vcfxb committed Jul 9, 2021
1 parent d2a1392 commit ed43721
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 6 deletions.
29 changes: 23 additions & 6 deletions src/web/services/meetings/edit.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
//! Services to support meeting edits.
use actix_web::{
web::{ServiceConfig, Path, Query},
HttpResponse
};
use actix_web::{web::{ServiceConfig, Path, Query}, HttpResponse, HttpRequest};
use crate::error::TelescopeError;
use crate::web::services::auth::identity::AuthenticationCookie;
use crate::api::rcos::meetings::{
Expand All @@ -24,10 +21,14 @@ use actix_web::web::Form;
use crate::api::rcos::meetings::creation::create::normalize_url;
use actix_web::http::header::LOCATION;
use crate::templates::Template;
use crate::api::rcos::meetings::edit::EditHostSelection;

/// The Handlebars file for the meeting edit form.
const MEETING_EDIT_FORM: &'static str = "meetings/edit/form";

/// The Handlebars file for the host selection page.
const HOST_SELECTION_TEMPLATE: &'static str = "meetings/edit/host_selection";

/// Register the meeting edit services.
pub fn register(config: &mut ServiceConfig) {
config
Expand Down Expand Up @@ -342,6 +343,22 @@ async fn submit_meeting_edits(

/// Host selection page.
#[get("/meeting/{meeting_id}/edit/select_host")]
async fn host_selection() -> Result<Template, TelescopeError> {
Err(TelescopeError::NotImplemented)
async fn host_selection(
Path(meeting_id): Path<i64>,
auth: AuthenticationCookie,
req: HttpRequest,
) -> Result<Template, TelescopeError> {
// Check that the user can edit this meeting.
let viewer = auth.get_rcos_username_or_error().await?;
if !AuthorizationFor::get(Some(viewer)).await?.can_edit_by_id(meeting_id).await? {
return Err(TelescopeError::Forbidden);
}

// Get host selection.
let data = EditHostSelection::get(meeting_id).await?;

// Create host selection page template.
let mut template: Template = Template::new(HOST_SELECTION_TEMPLATE);
template.set_field("data", data);
return template.render_into_page(&req, "Select Host").await;
}
25 changes: 25 additions & 0 deletions templates/meetings/edit/host_selection.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{{! Template for selecting a host while editing a meeting }}

{{#with data.meetings_by_pk}}
{{! No Host }}
<div class="card text-dark mb-2">
<div class="card-body">
<div class="row justify-content-center">
<div class="col-12 col-md-4">
<h2>No Host</h2>
</div>

<div class="col-12 col-md-8">
<a href="/meeting/{{meeting_id}}/edit?{{url_encode set_host=""}}" class="btn btn-primary w-100">
Select no host.
</a>
</div>
</div>
</div>
</div>


{{else}}
Meeting Not Found. Please contact a coordinator or create a GitHub Issue.
This should never happen.
{{/with}}

0 comments on commit ed43721

Please sign in to comment.