forked from lobsters/lobsters
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bunch of extraneous Rails 5.2 churn in db/schema.rb that I'm accepting here.
- Loading branch information
Showing
16 changed files
with
156 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class ModNotesController < ModController | ||
before_action :require_logged_in_moderator | ||
|
||
def index | ||
@notes = period(ModNote.includes(:moderator, :user).all) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
class ModNote < ApplicationRecord | ||
belongs_to :moderator, | ||
:class_name => "User", | ||
:foreign_key => "moderator_user_id", | ||
:inverse_of => :moderations | ||
belongs_to :user | ||
|
||
scope :recent, -> { where('created_at >= ?', 1.week.ago).order('created_at desc') } | ||
scope :for, ->(user) { includes(:moderator).where('user_id = ?', user).order('created_at desc') } | ||
|
||
validates :moderator, :user, :note, presence: true | ||
|
||
def note=(n) | ||
self[:note] = n.to_s.strip | ||
self.markeddown_note = self.generated_markeddown | ||
end | ||
|
||
def generated_markeddown | ||
Markdowner.to_html(self.note) | ||
end | ||
|
||
def self.create_from_message(message, moderator) | ||
user = moderator.id == message.recipient.id ? message.author : message.recipient | ||
ModNote.create!( | ||
moderator: moderator, | ||
user: user, | ||
created_at: message.created_at, | ||
note: <<~NOTE | ||
*#{message.author.username} #{message.hat ? message.hat.to_txt : ''}-> #{message.recipient.username}*: #{message.subject} | ||
#{message.body} | ||
NOTE | ||
) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<table class="data zebra tall" width="100%" cellspacing=0> | ||
<tr> | ||
<th>Mod → User/When</th> | ||
<th>Note</th> | ||
</tr> | ||
<% mod_notes.each do |note| %> | ||
<tr class="nobottom"> | ||
<td> | ||
<%= note.moderator.username %> | ||
→ | ||
<%= link_to note.user.username, user_path(note.user) %> | ||
<br> | ||
<%= raw note.created_at.strftime("%Y-%m-%d %H:%M %z") %> | ||
</td> | ||
<td><%= raw note.markeddown_note %></td> | ||
</tr> | ||
<% end %> | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<%= render partial: 'mod/nav' %> | ||
|
||
<%= render partial: 'table', locals: { | ||
mod_notes: @notes | ||
} %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class CreateModNotes < ActiveRecord::Migration[5.2] | ||
def change | ||
create_table :mod_notes do |t| | ||
t.integer :moderator_user_id, null: false | ||
t.integer :user_id, null: false | ||
t.text :note, null: false | ||
t.text :markeddown_note, null: false | ||
t.datetime :created_at, null: false | ||
end | ||
|
||
add_index :mod_notes, [:id, :user_id] | ||
end | ||
end |
Oops, something went wrong.