<commit_before><% path = @lesson.persisted? ? admin_lesson_path(@lesson) : admin_lessons_path %> 
<%= form_for @lesson, url: path do |f| %>
  <% if @lesson.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@lesson.errors.count, "error") %> prohibited this lesson from being saved:</h2>

      <ul>
      <% @lesson.errors.full_messages.each do |message| %>
        <li><%= message %></li>
      <% end %>
      </ul>
    </div>
  <% end %>

  <div class="field">
    <%= label_tag :project_slug, "Project" %>
    <select id="project_slug" name="project_slug">
      <%= options_for_select ProjectSet.all.map { |p| [p.title, p.slug] }, ProjectSet.count %>
    </select>
  </div>
  
  <div class="field">
    <%= label_tag :project_level %>
    <select id="project_level" name="project_level">
      <%= options_for_select Project.levels.map { |l| [l[0].capitalize, l[0]] }, Project.levels.length %>
    </select>
  </div>

  <div class="field">
    <%= f.label :title %>
    <%= f.text_field :title %>
  </div>

  <%= render "shared/form_attachment", 
    form: f, 
    entity: @project,
    attribute: :overview,
    label: "Lesson Overview PDF" %>

  <%= render "shared/form_attachment", 
    form: f, 
    entity: @project,
    attribute: :example_image,
    label: "Example Image" %>

  <%= render "shared/form_attachment", 
    form: f, 
    entity: @project,
    attribute: :inspiration_image,
    label: "Inspiration Image" %>

  <div class="field">
    <%= f.label :inspiration_image_description %>
    <%= f.text_field :inspiration_image_description %>
  </div>
  
  <div class="field">
    <%= f.label :video_uri, "Video URL" %>
    <%= f.text_field :video_uri %>
  </div>

  <%= render "shared/form_sections", form: f %>

  <div class="actions">
    <%= f.submit %>
  </div>
<% end %>
<commit_msg>Only enable changing of Projects/Levels when first creating a Lesson<commit_after><% path = @lesson.persisted? ? admin_lesson_path(@lesson) : admin_lessons_path %> 
<%= form_for @lesson, url: path do |f| %>
  <% if @lesson.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@lesson.errors.count, "error") %> prohibited this lesson from being saved:</h2>

      <ul>
      <% @lesson.errors.full_messages.each do |message| %>
        <li><%= message %></li>
      <% end %>
      </ul>
    </div>
  <% end %>

  <% if @lesson.new_record? %>
  <div class="field">
    <%= label_tag :project_slug, "Project" %>
    <select id="project_slug" name="project_slug">
      <%= options_for_select ProjectSet.all.map { |p| [p.title, p.slug] }, ProjectSet.count %>
    </select>
  </div>
  
  <div class="field">
    <%= label_tag :project_level %>
    <select id="project_level" name="project_level">
      <%= options_for_select Project.levels.map { |l| [l[0].capitalize, l[0]] }, Project.levels.length %>
    </select>
  </div>
  <% end %>

  <div class="field">
    <%= f.label :title %>
    <%= f.text_field :title %>
  </div>

  <%= render "shared/form_attachment", 
    form: f, 
    entity: @project,
    attribute: :overview,
    label: "Lesson Overview PDF" %>

  <%= render "shared/form_attachment", 
    form: f, 
    entity: @project,
    attribute: :example_image,
    label: "Example Image" %>

  <%= render "shared/form_attachment", 
    form: f, 
    entity: @project,
    attribute: :inspiration_image,
    label: "Inspiration Image" %>

  <div class="field">
    <%= f.label :inspiration_image_description %>
    <%= f.text_field :inspiration_image_description %>
  </div>
  
  <div class="field">
    <%= f.label :video_uri, "Video URL" %>
    <%= f.text_field :video_uri %>
  </div>

  <%= render "shared/form_sections", form: f %>

  <div class="actions">
    <%= f.submit %>
  </div>
<% end %>

{'fraction_non_alphanumeric': 0.18636847710330137, 'fraction_numerical': 0.002129925452609159, 'mean_word_length': 3.1605758582502768, 'pattern_counts': {'":': 0, '<': 101, '<?xml version=': 0, '>': 101, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2123209', 'n_tokens_mistral': 1450, 'n_tokens_neox': 1309, 'n_words': 276}