$newline never
<dl .deflist>
  $if not (null news) || mayCreateNews
    <dt .deflist__dt>
      _{MsgCourseNews}
      $if not visibleNews
        \ #{iconInvisible}
    <dd .deflist__dd>
      $if not (null news)
        <ul .course-news .list--iconless>
          $forall (cID, CourseNews{courseNewsTitle, courseNewsSummary, courseNewsContent}, isVisible, files, lastEditText, mayEditNews, mayDelete, archiveUrl) <- news
            <li .course-news-item ##{"news-" <> toPathPiece cID}>
              $case (courseNewsTitle, courseNewsSummary)
$#                 $of (Just title, Just summary)
$#                   <div .div-h3 .course-news-item__title>
$#                     ^{modal (toWidget title) (Left (SomeRoute (CNewsR tid ssh csh cID CNShowR)))}
$#                     $if not isVisible
$#                       \ #{iconInvisible}
$#                   <p .course-news-item__summary>
$#                     #{summary}
                $of (_, Just summary)
                  $if not isVisible
                    <h3 .course-news-item__title>
                      #{iconInvisible}
                  <div .div-p .course-news-item__summary>
                    ^{modal (toWidget summary) (Left (SomeRoute (CNewsR tid ssh csh cID CNShowR)))}
                $of (Just title, Nothing)
                  <h3 .course-news-item__title>
                    #{title}
                    $if not isVisible
                      \ #{iconInvisible}
                  <p .course-news-item__content>
                    #{courseNewsContent}
                $of (Nothing, Nothing)
                  $if not isVisible
                    <h3 .course-news-item__title>
                      #{iconInvisible}
                  <p .course-news-item__content>
                    #{courseNewsContent}
              $if showNewsFiles files
                <ul .course-news-item__files-links .list--inline .list--comma-separated>
                  $forall ((_, fp), fileUrl) <- filter (not . view (_1 . _1)) files
                    <li .course-news-item__file-link>
                      <a href=#{fileUrl}>
                        #{fp}
              $elseif not (null files)
                <p .course-news-item__files-link>
                  <a href=#{archiveUrl}>
                    #{iconFileZip}
                    \ _{MsgCourseNewsFiles}
              <p .course-news-item__last-edit>
                _{MsgCourseNewsLastEdited lastEditText}
              $if mayEditNews || mayDelete
                <ul .course-news-item__actions .list--inline .list--comma-separated>
                  $if mayEditNews
                    <li>
                      ^{modal (i18n MsgCourseNewsActionEdit) (Left (SomeRoute (CNewsR tid ssh csh cID CNEditR)))}
                  $if mayDelete
                    <li>
                      ^{modal (i18n MsgCourseNewsActionDelete) (Left (SomeRoute (CNewsR tid ssh csh cID CNDeleteR)))}
      $if mayCreateNews
        <div .div-p>
          ^{modal (i18n MsgCourseNewsActionCreate) (Left (SomeRoute (CourseR tid ssh csh CNewsNewR)))}
            
  
  $maybe descr <- courseDescription course
    <dt .deflist__dt>_{MsgCourseDescription}
    <dd .deflist__dd>
      <div>
        #{descr}

  <dt .deflist__dt>_{MsgCourseSchool}
  <dd .deflist__dd>
    #{schoolName}

  $with numlecs <- length lecturers
    $if numlecs /= 0
      $if numlecs > 1
        <dt .deflist__dt>_{MsgLecturersFor}
      $else
        <dt .deflist__dt>_{MsgLecturerFor}
      <dd .deflist__dd>
        <ul .list--inline .list--comma-separated>
          $forall lect <- lecturers
            <li>^{nameEmailWidget' lect}
  $with numassi <- length assistants
    $if numassi /= 0
      $if numassi > 1
        <dt .deflist__dt>_{MsgAssistantsFor}
      $else
        <dt .deflist__dt>_{MsgAssistantFor}
      <dd .deflist__dd>
        <ul .list--inline .list--comma-separated>
          $forall assi <- assistants
            <li>^{nameEmailWidget' assi}

  $with numtutor <- length tutors
    $if numtutor /= 0
      <dt .deflist__dt>_{MsgTutorsFor numtutor}
      <dd .deflist__dd>
        <ul .list--inline .list--comma-separated>
          $forall tutor <- tutors
            <li>^{nameEmailWidget' tutor}

  $with numcorrector <- length correctors
    $if numcorrector /= 0
      <dt .deflist__dt>_{MsgCorrectorsFor numcorrector}
      <dd .deflist__dd>
        <ul .list--inline .list--comma-separated>
          $forall corrector <- correctors
            <li>^{nameEmailWidget' corrector}

  $maybe link <- courseLinkExternal course
    <dt .deflist__dt>_{MsgCourseHomepageExternal}
    <dd .deflist__dd>
      <a href=#{uriToString id link mempty} target="_blank" rel="noopener" title="_{MsgCourseHomepageExternal}">
        #{iconLink}
        \ #{uriToString id link mempty}

$#    $if NTop (Just 0) < NTop (courseCapacity course)
  <dt .deflist__dt>_{MsgCourseParticipantsHeading}
  <dd .deflist__dd>
    $maybe capacity <- courseCapacity course
      _{MsgCourseParticipantsCountOf participants capacity}
    $nothing
      _{MsgCourseParticipantsCount participants}
  
  $if mayEdit
    <dt .deflist__dt>
      $if isJust courseVisibleFrom && isNothing courseVisibleTo
        _{MsgCourseVisibleFrom}
      $else
        _{MsgCourseVisibility}
      \ #{iconInvisible}
    <dd .deflist__dd>
      <p>
        $maybe visFrom <- courseVisibleFrom
          ^{formatTimeRangeW SelFormatDateTime visFrom courseVisibleTo}
          <br />
        $if NTop (Just now) < NTop courseVisibleFrom
          $if hasAllocationRegistrationOpen
            _{MsgCourseInvisibleOverridenByAllocation}
          $else
            _{MsgCourseInvisible}
  
  $maybe (Allocation{allocationName, allocationRegisterByCourse}, url) <- mAllocation'
    <dt .deflist__dt>_{MsgCourseAllocation}
    <dd .deflist__dd>
      <a href=#{url}>
        #{allocationName}
    $maybe regFrom <- allocationRegisterByCourse
      $maybe regFrom' <- courseRegisterFrom course
        $with regFrom'' <- max regFrom regFrom'
          $if NTop (Just regFrom'') <= NTop (courseRegisterTo course)
            <dt .deflist__dt>_{MsgCourseDirectRegistrationInterval}
            <dd .deflist__dd>
              <p>
                ^{formatTimeRangeW SelFormatDateTime regFrom'' (courseRegisterTo course)}
              $maybe dereg <- mDereg
                <p .emph>
                  _{MsgCourseDeregisterUntil dereg}
  $nothing
    $maybe regFrom <- courseRegisterFrom course
      <dt .deflist__dt>_{MsgCourseRegistrationInterval}
      <dd .deflist__dd>
        <p>
          ^{formatTimeRangeW SelFormatDateTime regFrom (courseRegisterTo course)}
        $maybe dereg <- mDereg
          <p .emph>
            _{MsgCourseDeregisterUntil dereg}
  
  $maybe aInst <- courseApplicationsInstructions course
    <dt .deflist__dt>
      $if courseApplicationsRequired course
        _{MsgCourseApplicationInstructionsApplication}
      $else
        _{MsgCourseApplicationInstructionsRegistration}
    <dd .deflist__dd>
      <div>
        #{aInst}
      $maybe templateUrl <- mApplicationTemplate
        <p>
          <a href=#{templateUrl}>
            #{iconRegisterTemplate} #
            $if courseApplicationsRequired course
              _{MsgCourseApplicationTemplateApplication}
            $else
              _{MsgCourseApplicationTemplateRegistration}
  $nothing
    $maybe templateUrl <- mApplicationTemplate
      <dt .deflist__dt>
        $if courseApplicationsRequired course
          _{MsgCourseApplicationInstructionsApplication}
        $else
          _{MsgCourseApplicationInstructionsRegistration}
      <dd .deflist__dd>
        <a href=#{templateUrl}>
          #{iconRegisterTemplate} #
          $if courseApplicationsRequired course
            _{MsgCourseApplicationTemplateApplication}
          $else
            _{MsgCourseApplicationTemplateRegistration}

  $maybe mGroup <- submissionGroup
    <dt .deflist__dt>
      _{MsgSubmissionGroup}
    <dd .deflist__dd>
      $maybe groupName <- mGroup
        #{groupName}
      $nothing
        <i>
          _{MsgNoSubmissionGroup}

  $if registrationOpen || isJust registration
    <dt .deflist__dt>
      _{MsgCourseRegistration}
    <dd .deflist__dd>
      <div .course__registration-status>
        $maybe CourseParticipant{courseParticipantRegistration} <- registration
          _{MsgRegisteredSince}
          \ ^{formatTimeW SelFormatDateTime courseParticipantRegistration}
        $nothing
          _{MsgNotRegistered}
      <div .course__registration>
        $if registrationOpen
          $# regForm is defined through templates/widgets/registerForm
          ^{regForm}
          $if (isJust mApplication && courseApplicationsRequired course) && mayReRegister
            <p .explanation>
              _{MsgCourseApplicationDeleteToEdit}
  
  <dt .deflist__dt>
    _{MsgCourseMaterial}
  <dd .deflist__dd>
    $if mayViewSheets
      <p>
        $if mayViewAnySheet
          _{MsgCourseSheetsFoundHere}: #
          <a href=@{CourseR tid ssh csh SheetListR}>
            _{MsgMenuSheetList}
        $else
          _{MsgCourseSheetsNoneVisible}
    $if mayViewMaterials
      <p>
        $if mayViewAnyMaterial
          _{MsgCourseMaterialsFoundHere}: #
          <a href=@{CourseR tid ssh csh MaterialListR}>
            _{MsgMenuMaterialList}
        $else
          _{MsgCourseMaterialsNoneVisible}
    <p .explanation>
      $if courseMaterialFree course
        _{MsgCourseMaterialFree}
      $else
        _{MsgCourseMaterialNotFree}
  
  $if hasExams
    <dt .deflist__dt>_{MsgCourseExams}
    <dd .deflist__dd>
      ^{examTable}
  $if not (null events) || mayCreateEvents
    <dt .deflist__dt>
      _{MsgCourseEvents}
      $if null events
        \ #{iconInvisible}
    <dd .deflist__dd>
      <div uw-hide-columns="events">
        <div .scrolltable .scrolltable--bordered>
          <table .table .table--striped .table--hover>
            <thead>
              <tr .table__row .table__row--head>
                <th .table__th uw-hide-column-header="type">
                  _{MsgCourseEventType}
                <th .table__th uw-hide-column-header="time">
                  _{MsgCourseEventTime}
                <th .table__th uw-hide-column-header="room">
                  _{MsgCourseEventRoom}
                <th .table__th uw-hide-column-header="note" :hiddenEventNotes:.course-event-note--hidden>
                  _{MsgCourseEventNote}
                $# TODO: merge with actions column
                $if is _Just mbAuth
                  <th .table__th uw-hide-column-header="schedule-actions">
                    _{MsgScheduleOptActions}
                $if mayCreateEvents
                  <th .table__th uw-hide-column-header="actions">
                    _{MsgCourseEventActions}
                    \ #{iconInvisible}
            <tbody>
              $forall (cID, CourseEvent{courseEventType, courseEventTime, courseEventRoom, courseEventNote}, showRoom, courseEventCurrentOpt, mEventScheduleOpt) <- events
                <tr .table__row ##{"event-" <> toPathPiece cID}>
                  <td .table__td>
                    <div .table__td-content>
                      #{courseEventType}
                  <td .table__td>
                    <div .table__td-content>
                      ^{occurrencesWidget courseEventTime}
                  <td .table__td>
                    $if showRoom
                      <div .table__td-content>
                        $maybe room <- courseEventRoom
                          ^{roomReferenceWidget room}
                        $nothing
                          _{MsgCourseEventRoomIsUnset}
                    $else
                      <div .table__td-content .explanation>
                        _{MsgCourseEventRoomIsHidden}
                  <td .table__td :hiddenEventNotes:.course-event-note--hidden>
                    <div .table__td-content>
                      #{courseEventNote}
                  $# TODO: merge with actions column
                  $if is _Just mbAuth
                    <td .table__td>
                      <div .table__td-content>
                        <a .btn .btn-primary href=@{CEventR tid ssh csh cID (CEvScheduleOptSetR (not courseEventCurrentOpt))}>
                          _{bool MsgScheduleOptIn MsgScheduleOptOut courseEventCurrentOpt}
                        $if is _Just mEventScheduleOpt
                          <a .btn .btn-primary href=@{CEventR tid ssh csh cID CEvScheduleOptDelR}>
                            _{MsgScheduleOptDelete}
                  $if mayCreateEvents
                    <td .table__td>
                      <ul .list--inline .list--iconless .list--comma-separated>
                        <li>
                          ^{modal (i18n MsgCourseEventsActionEdit) (Left (SomeRoute (CEventR tid ssh csh cID CEvEditR)))}
                        <li>
                          ^{modal (i18n MsgCourseEventsActionDelete) (Left (SomeRoute (CEventR tid ssh csh cID CEvDeleteR)))}
            $if mayCreateEvents
              <tfoot>
                <tr .table__row .table__row--foot>
                  <td>
                  <td>
                  <td>
                  <td :hiddenEventNotes:.course-event-note--hidden>
                  <td .table__td>
                    <div .table__td-content>
                      ^{modal (i18n MsgCourseEventsActionCreate) (Left (SomeRoute (CourseR tid ssh csh CEventsNewR)))}
          
                  
  $if hasTutorials
    <dt .deflist__dt>_{MsgCourseTutorials}
    <dd .deflist__dd>
      ^{tutorialTable}

  $maybe (_, user) <- mbAuth
    <dt .deflist__dt>
      _{MsgScheduleOptActions}
    <dd .deflist__dd>
      <a .btn .btn-primary href=@{CourseR tid ssh csh (CScheduleOptSetR (not (courseScheduleOptToggleValue user)))}>
        _{bool MsgCourseScheduleOptIn MsgCourseScheduleOptOut (courseScheduleOptToggleValue user)}
      $if is _Just mCourseScheduleOpt
        <a .btn .btn-primary href=@{CourseR tid ssh csh CScheduleOptDelR}>
          _{MsgCourseScheduleOptDelete}
