<%
# Copyright (C) 2011 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
%>

<% event ||= nil %>
<% is_assignment = event.respond_to?(:due_at)
  full_id = 'event_blank'
  if event
    if is_assignment
      full_id = 'event_assignment_' + event.id.to_s
    else
      full_id = 'event_calendar_event_' + event.id.to_s
    end
  end
  title_text = event ? ("#{event.title} - #{time_string(event.start_at, event.end_at)}") : ""
  title_text = t(:event_title, "due: %{event_title}", :event_title => title_text) if title_text && !title_text.empty? && is_assignment
%>
<div class="calendar_event <%= 'assignment' if is_assignment %> <%= "group_#{event.try_rescue(:context_type).try_rescue(:downcase)}_#{event.try_rescue(:context_id)}" %> <%= "draggable" if can_do(event, @current_user, :update) %>" id="<%= full_id %>" style="<%= event ? '' : 'display: none;' %>" title="<%= title_text %>">
  <div>&nbsp;</div>
  <div class="calendar_event_text">
    <span class="screenreader-only calendar-name-text"></span>
    <span class="due_text">
      <%= t :due, "due" %>
    </span>
  <% if is_assignment %>
    <a href="<%= context_url(event.context, :context_assignment_url, event.id) %>" class="title"><%= event.title rescue ""%></a>
  <% else %>
    <a href="<%= context_url(event.context, :context_calendar_event_url, event.id) rescue '#' %>" class="title"><%= event.title rescue ""%></a>
  <% end %>
  </div>
</div>