Skip to content

Commit

Permalink
Corrections in admin interface
Browse files Browse the repository at this point in the history
  • Loading branch information
kkaltrine committed Mar 31, 2016
1 parent 01488a3 commit 48d6287
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 42 deletions.
11 changes: 5 additions & 6 deletions app/dashboards/postulation_dashboard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ class PostulationDashboard < Administrate::BaseDashboard
# on pages throughout the dashboard.
ATTRIBUTE_TYPES = {
id: Field::Number,
teacher: Field::BelongsTo,
user: Field::BelongsTo.with_options(class_name: "Teacher"),
teacher: Field::BelongsTo.with_options(class_name: "Teacher"),
interview_ok: Field::Boolean,
avatar_ok: Field::Boolean,
gen_informations_ok: Field::Boolean,
Expand All @@ -27,7 +28,6 @@ class PostulationDashboard < Administrate::BaseDashboard
COLLECTION_ATTRIBUTES = [
:teacher,
:id,
:user_id,
:interview_ok,
:avatar_ok,
:gen_informations_ok,
Expand All @@ -37,13 +37,13 @@ class PostulationDashboard < Administrate::BaseDashboard
# SHOW_PAGE_ATTRIBUTES
# an array of attributes that will be displayed on the model's show page.
SHOW_PAGE_ATTRIBUTES = [
:teacher,
:user,
:id,
:teacher,
:interview_ok,
:avatar_ok,
:gen_informations_ok,
:advert_ok,
:user_id,
:created_at,
:updated_at,
]
Expand All @@ -52,12 +52,11 @@ class PostulationDashboard < Administrate::BaseDashboard
# an array of attributes that will be displayed
# on the model's form (`new` and `edit`) pages.
FORM_ATTRIBUTES = [
:teacher,
:user,
:interview_ok,
:avatar_ok,
:gen_informations_ok,
:advert_ok,
:user_id,
]

# Overwrite this method to customize how postulations are displayed
Expand Down
4 changes: 0 additions & 4 deletions app/dashboards/student_dashboard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,6 @@ class StudentDashboard < Administrate::BaseDashboard
:unlock_token,
:locked_at,
:admin,
:avatar_file_name,
:avatar_content_type,
:avatar_file_size,
:avatar_updated_at,
]

# Overwrite this method to customize how students are displayed
Expand Down
4 changes: 0 additions & 4 deletions app/dashboards/teacher_dashboard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,6 @@ class TeacherDashboard < Administrate::BaseDashboard
:unlock_token,
:locked_at,
:admin,
:avatar_file_name,
:avatar_content_type,
:avatar_file_size,
:avatar_updated_at,
]

# Overwrite this method to customize how teachers are displayed
Expand Down
4 changes: 0 additions & 4 deletions app/dashboards/user_dashboard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,6 @@ class UserDashboard < Administrate::BaseDashboard
:unlock_token,
:locked_at,
:admin,
:avatar_file_name,
:avatar_content_type,
:avatar_file_size,
:avatar_updated_at,
]

# Overwrite this method to customize how users are displayed
Expand Down
2 changes: 1 addition & 1 deletion app/models/postulation.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Postulation < ActiveRecord::Base

belongs_to :teacher
belongs_to :teacher, :foreign_key => :user_id, class_name: 'Teacher'
end
7 changes: 6 additions & 1 deletion app/models/teacher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ class Teacher < Student
has_one :postulation, foreign_key: "user_id"
has_many :degrees, foreign_key: "user_id"
acts_as_reader
after_create :create_gallery, :create_postulation

def self.reader_scope
where(:is_admin => true)
end
Expand All @@ -29,5 +31,8 @@ def accept_postulance
def is_prof
self.postulance_accepted?
end

# Méthode permettant de créer une postulation
def create_postulation
Postulation.create(:user_id => self.id)
end
end
9 changes: 2 additions & 7 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class User < ActiveRecord::Base
has_one :gallery
has_many :adverts

# on crée une postulation et une gallery après avoir créé le user
after_create :create_gallery, :create_postulation
# on crée une gallery après avoir créé le user
after_create :create_gallery

has_many :sent_comment, :class_name => 'Comment', :foreign_key => 'sender_id'
has_many :received_comment, :class_name => 'Comment', :foreign_key => 'subject_id'
Expand All @@ -56,11 +56,6 @@ def create_gallery
Gallery.create(:user_id => self.id)
end

# Méthode permettant de créer une postulation
def create_postulation
Postulation.create(:user_id => self.id)
end

# Méthode liée au crop de l'avatar, elle permet de savoir si une modification a été faite
def cropping?
!crop_x.blank? && !crop_y.blank? && !crop_w.blank? && !crop_h.blank?
Expand Down
30 changes: 15 additions & 15 deletions app/views/fields/mailboxer_conversation_field/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
<% end %>
</table>
<hr style="border-width: 6px;">
<table style="width: 68%; table-layout: fixed;">
<table style="width: auto; table-layout: fixed;">
<% @conversation.messages.each do |message| %>
<% if message.sender.id == @first %>
<tr>
<td style="background-color: darkgray;">
<td style="background-color: darkgray;width: 25%;">
<%= image_tag(message.sender.avatar.url(:small), :style => " background-color: white;
border: 1px solid #d9d9d9;
border-radius: 25px;
Expand All @@ -47,30 +47,28 @@
width: 50px;
overflow: hidden;
text-align: center;
img { width: 100% }") %><br> <i><%= message.sender.email %></i>
</td>
<td>
<p style=" padding: 0.5rem;
img { width: 100% }") %><small style=" padding: 0.5rem;
overflow: hidden;
display: flex; word-break: break-all;white-space: pre-wrap;">
display: flex; word-break: break-all;white-space: pre-wrap;"><%= message.sender.email %></small>
</td>
<td style=" width: 50%;
word-break: break-all;white-space: inherit;">
<%= message.body %>
<time datetime="<%= message.created_at %>" title="<%= message.created_at.strftime("%d %b %Y at %I:%M%p") %>">
</time>
</p></td>
</td>
<td></td>
</tr>
<% else %>
<tr>
<td></td>
<td>
<p style=" padding: 0.5rem;
overflow: hidden;
display: flex; word-break: break-all;white-space: pre-wrap;">
<td style=" width: 50%;
word-break: break-all;white-space: inherit;">
<%= message.body %>
<time datetime="<%= message.created_at %>" title="<%= message.created_at.strftime("%d %b %Y at %I:%M%p") %>">
</time>
</p></td>
<td style="background-color: darkslategrey;">
</td>
<td style="background-color: darkslategrey;width: 25%;">
<%= image_tag(message.sender.avatar.url(:small), :style => " background-color: white;
border: 1px solid #d9d9d9;
border-radius: 25px;
Expand All @@ -80,7 +78,9 @@
width: 50px;
overflow: hidden;
text-align: center;
img { width: 100% }") %><br> <i><%= message.sender.email %></i></td>
img { width: 100% }") %><small style=" padding: 0.5rem;
overflow: hidden;
display: flex; word-break: break-all;white-space: pre-wrap;"><%= message.sender.email %></small></td>
</tr>
<% end %>
<% end %>
Expand Down

0 comments on commit 48d6287

Please sign in to comment.