diff --git a/README.md b/README.md index 0963b09..eeb1118 100644 --- a/README.md +++ b/README.md @@ -1 +1,14 @@ # Lecture Attendance Management System + +## Alterations + +### Continuum Mechanics + +```ruby +continuum_mechanics = Course.find(nil) + +continuum_mechanics.import_from_calendar! +continuum_mechanics.lectures.filter { |lecture| lecture.start_time.monday? }.map {|lecture| lecture.update!(kind: Lecture.kinds[:problems_class]) } +continuum_mechanics.lectures.find_by(start_time: '2023-10-02 08:15:00.000000').destroy! +continuum_mechanics.renumber_lectures! +``` diff --git a/app/assets/stylesheets/application.tailwind.css b/app/assets/stylesheets/application.tailwind.css index 8666d2f..c6f38c5 100644 --- a/app/assets/stylesheets/application.tailwind.css +++ b/app/assets/stylesheets/application.tailwind.css @@ -2,6 +2,10 @@ @tailwind components; @tailwind utilities; +.action-button { + @apply rounded bg-indigo-600 px-2 py-1 font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600; +} + /* @layer components { diff --git a/app/controllers/lecture_controller.rb b/app/controllers/lecture_controller.rb new file mode 100644 index 0000000..45ad7cf --- /dev/null +++ b/app/controllers/lecture_controller.rb @@ -0,0 +1,14 @@ +class LectureController < ApplicationController + def start + lecture = Lecture.find(params[:id]) + + Toggl::start_time_entry( + description: lecture.title, + project_id: lecture.course.toggl_project, + ) + + if lecture.recording.present? + redirect_to lecture.recording.recording_url, allow_other_host: true + end + end +end diff --git a/app/helpers/lecture_helper.rb b/app/helpers/lecture_helper.rb new file mode 100644 index 0000000..397536c --- /dev/null +++ b/app/helpers/lecture_helper.rb @@ -0,0 +1,2 @@ +module LectureHelper +end diff --git a/app/lib/toggl.rb b/app/lib/toggl.rb index b991db4..7f43956 100644 --- a/app/lib/toggl.rb +++ b/app/lib/toggl.rb @@ -10,4 +10,17 @@ module Toggl headers: { 'Content-Type' => 'application/json', 'Accept' => 'application/json' } ).body) end + + def self.start_time_entry(description:, project_id:) + HTTParty.post( + "http://localhost:3005/start_time_entry", + body: { + "created_with": "Attendance Tracker", + "description": description, + "duration": -1, + "project_id": project_id, + }.to_json, + headers: { 'Content-Type' => 'application/json', 'Accept' => 'application/json' } + ) + end end diff --git a/app/models/course.rb b/app/models/course.rb index fb41db0..0faf14d 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -61,6 +61,7 @@ class Course < ApplicationRecord end end + # What should this do for existing attendances? def renumber_lectures! lectures.group_by(&:kind).each do |kind, lectures| lectures.sort_by(&:start_time).each_with_index do |lecture, index| diff --git a/app/models/lecture.rb b/app/models/lecture.rb index b87cfbb..e31b27d 100644 --- a/app/models/lecture.rb +++ b/app/models/lecture.rb @@ -5,7 +5,7 @@ class Lecture < ApplicationRecord enum :kind, [ :lecture, - :problem_class, + :problems_class, ], default: :lecture def week_number diff --git a/app/views/attendance_tracker/index.html.erb b/app/views/attendance_tracker/index.html.erb index 9ebbdd4..024d4a3 100644 --- a/app/views/attendance_tracker/index.html.erb +++ b/app/views/attendance_tracker/index.html.erb @@ -66,11 +66,14 @@
Find me in app/views/lecture/start.html.erb
+