Skip to content

Commit

Permalink
Merge pull request #52 from alphasusu/user-profile-pages
Browse files Browse the repository at this point in the history
User Profile Pages
  • Loading branch information
danpalmer committed Feb 23, 2014
2 parents 05f7a13 + 069bd5b commit 914de94
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 55 deletions.
25 changes: 20 additions & 5 deletions app/assets/stylesheets/profiles.css.scss
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
.edit-profile {
margin-top: 40px !important;
}

.avatar {
margin-bottom: 10px;
width: 100px;
height: 100px;
}
.profile-picture {
margin-bottom: 10px;
height: 100px;
width: auto;
float: left;
margin-right: 10px;
}

.avatar {
display:inline-block;
margin-right: 5px;
border-radius: 16px;
width: 32px;
height: 32px;
}

.profile .header {
h1 { margin-bottom: 0; }
h3 { margin-top: -10px; color: #777; }
}
2 changes: 2 additions & 0 deletions app/controllers/profiles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ class ProfilesController < ApplicationController

def show
@positions = Officer.where(user: @profile)
@blog_posts = BlogPost.where(author: @profile).limit(3).order(:created_at)
end

def me
@profile = current_user
@positions = Officer.where(user: @profile)
@blog_posts = BlogPost.where(author: @profile).limit(3).order(:created_at)
render :show
end

Expand Down
52 changes: 27 additions & 25 deletions app/views/profiles/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
}) do |f| %>
<div class="row">
<div class="large-3 columns left">
<%= image_tag @profile.get_avatar_url(:medium), size: "100x100", class: "avatar", alt: @profile.name %>
<%= image_tag @profile.get_avatar_url(:medium), size: "100x100", class: "profile-picture", alt: @profile.name %>
</div>
<div class="large-9 columns">
<%= f.label :avatar %>
Expand All @@ -36,30 +36,32 @@
<% years_display = User.years.to_a.map {|y| [y[1], y[0]]} %>
<%= f.select :year, options_for_select(years_display, @profile.year), :include_blank => true %>
</div>
<div class="large-12 columns">
<%= f.label :email %>
<%= f.email_field :email %>
</div>
<div class="large-12 columns">
<% if @profile.is_a?(LocalUser) && @profile.pending_reconfirmation? %>
<p><strong>Currently waiting confirmation for: <%= @profile.unconfirmed_email %></strong></p>
<% end %>
</div>
<div class="large-12 columns <%= field_error_class @profile, :password %>">
<label>Password <small>Leave blank if you don't want to change it</small></label>
<%= f.password_field :password, :autocomplete => "off" %>
<%= field_error @profile, :password, "Password" %>
</div>
<div class="large-12 columns <%= field_error_class @profile, :password_confirmation %>">
<%= f.label :password_confirmation %>
<%= f.password_field :password_confirmation %>
<%= field_error @profile, :password_confirmation, "Confirmation" %>
</div>
<div class="large-12 columns <%= field_error_class @profile, :current_password %>">
<label>Current Password <small>Needed to change it</small></label>
<%= f.password_field :current_password %>
<%= field_error @profile, :current_password, "Password" %>
</div>
<% if @profile.is_a?(LocalUser) %>
<div class="large-12 columns">
<%= f.label :email %>
<%= f.email_field :email %>
</div>
<div class="large-12 columns">
<% if @profile.is_a?(LocalUser) && @profile.pending_reconfirmation? %>
<p><strong>Currently waiting confirmation for: <%= @profile.unconfirmed_email %></strong></p>
<% end %>
</div>
<div class="large-12 columns <%= field_error_class @profile, :password %>">
<label>Password <small>Leave blank if you don't want to change it</small></label>
<%= f.password_field :password, :autocomplete => "off" %>
<%= field_error @profile, :password, "Password" %>
</div>
<div class="large-12 columns <%= field_error_class @profile, :password_confirmation %>">
<%= f.label :password_confirmation %>
<%= f.password_field :password_confirmation %>
<%= field_error @profile, :password_confirmation, "Confirmation" %>
</div>
<div class="large-12 columns <%= field_error_class @profile, :current_password %>">
<label>Current Password <small>Needed to change it</small></label>
<%= f.password_field :current_password %>
<%= field_error @profile, :current_password, "Password" %>
</div>
<% end %>
<div class="large-12 columns">
<%= f.submit "Update", class: "button" %>
</div>
Expand Down
30 changes: 20 additions & 10 deletions app/views/profiles/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
<div class="row banner-offset">
<div class="large-3 columns">
<%= image_tag @profile.get_avatar_url(:medium), size: "100x100", class: "avatar", alt: @profile.name %>
</div>
<div class="large-9 columns">
<h1><%= @profile.name %></h1>
<% @positions.each do |position| %>
<h3><%= position.position_name %></h3>
<% end %>
<div class="row banner-offset profile">
<div class="large-6 medium-6 small-12 columns">
<div class="row">
<div class="large-12 columns header">
<%= image_tag @profile.get_avatar_url(:medium), size: "100x100", class: "profile-picture", alt: @profile.name %>
<h1><%= @profile.first_name %></h1>
<h3><%= @profile.last_name %></h3>
</div>
</div>
<% @positions.each do |position| %>
<h3><%= position.position_name %></h3>
<% if !position.description.blank? %>
<blockquote>
<p><%= position.description %></p>
</blockquote>
<% end %>
<% end %>
<% if @profile.course %>
<h4><%= @profile.course.name %> <small><%= @profile.get_year %></small></h4>
<% end %>

</div>
<div class="large-6 medium-6 small-12 columns">
<%= render partial: "blog_posts/preview", collection: @blog_posts %>
</div>
<div class="large-12 columns">
<% if @profile == current_user %>
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20140223155656_add_description_to_officer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddDescriptionToOfficer < ActiveRecord::Migration
def change
add_column :officers, :description, :text
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20140215155415) do
ActiveRecord::Schema.define(version: 20140223155656) do

create_table "academic_units", force: true do |t|
t.datetime "created_at"
Expand Down Expand Up @@ -172,6 +172,7 @@
t.string "year"
t.integer "faculty_id"
t.integer "academic_unit_id"
t.text "description"
end

add_index "officers", ["academic_unit_id"], name: "index_officers_on_academic_unit_id"
Expand Down
42 changes: 28 additions & 14 deletions lib/tasks/data_import.rake
Original file line number Diff line number Diff line change
Expand Up @@ -119,26 +119,40 @@ namespace "import" do

Officer.destroy_all
president = Officer.create(
:title => "Union President",
:user => @users[:president])
:title => "Union President",
:user => @users[:president],
:description => "Hello everyone, my name is David and I’m your Union President. SUSU is here to make sure that you can get the most out of your time here at Southampton. The Union is run by students, which means that you can represent students on your course, you can lead any of the 300+ student groups we have, you can vote to decide who should run the Union or you can run to lead it yourself. This is your student experience, your Union, and I’m here to make sure that it is as good as can possibly be.",
)
vp_education = Officer.create(
:title => "Vice-President Education",
:user => @users[:education])
:title => "Vice-President Education",
:user => @users[:education],
:description => "Hi, I’m David and I’m your Vice President Education. I’m here to represent your educational needs, making sure that the University is providing you with the best education possible, and do so by always being in contact with the University’s main Education staff members. I’m here to help you and to make sure that you’re getting a world class education, with world class facilities.",
)
vp_engagement = Officer.create(
:title => "Vice-President Engagement",
:user => @users[:engagement])
:title => "Vice-President Engagement",
:user => @users[:engagement],
:description => "Hi i'm Claire Gilbert your Vice President Engagement for 2013/2014. What that means is I help support enterprise groups, charity work, work with the local community and communicate what the union is to the student body. University is a time of exciting opportunities so go for it! Try something new! If you have any suggestions about any of the above please do get in contact and enjoy your year with SUSU.",
)
vp_sports = Officer.create(
:title => "Vice-President Sports Development",
:user => @users[:sports])
:title => "Vice-President Sports Development",
:user => @users[:sports],
:description => "Hi my name is Evan and I’m your Vice-President Sports Development. Over the next year I will head up the Sports Zone, which will shape your sporting experience here at Southampton. Whether you are interested in competing for the University or playing a sport recreationally, it does not matter. We cater to the needs of every student and allow you to develop your sporting skills, whatever your ability.",
)
vp_welfare = Officer.create(
:title => "Vice-President Welfare",
:user => @users[:welfare])
:title => "Vice-President Welfare",
:user => @users[:welfare],
:description => "Hi, I’m Beckie, your new Vice President for Welfare 2013/14. I’m here to make sure that you are healthy, safe and happy during your time at Southampton. There will be many exciting events and projects that you can get stuck into this year, giving you a chance to shout about the issues you care about, so I really hope you GET INVOLVED! :) It’s vital that you know that your union is here to support you every step of the way through your degree, so please don’t hesitate to contact The Advice Centre if you have any worries! -“How wonderful it is that nobody need wait a single moment before starting to improve the world.”- Anne Frank",
)
vp_community = Officer.create(
:title => "Vice-President Student Communities",
:user => @users[:communities])
:title => "Vice-President Student Communities",
:user => @users[:communities],
:description => "Hi, My name is Oli, and I am your Vice President Student Communities. As part of my role, I look after all International students, all Post Grad students, all students who study at Winchester, the National Oceanography Centre and Southampton General Hospital, as well as every student who lives in halls. I also work with other members of staff to make sure that all our decision making and activities we do are as diverse as possible. Along with the rest of the Sabbatical team, I’m here to make sure that you have a fantastic time at University, and thoroughly enjoy your time at Southampton.",
)
vp_democracy = Officer.create(
:title => "Vice-President Democracy & Creative Industries",
:user => @users[:democracy])
:title => "Vice-President Democracy & Creative Industries",
:user => @users[:democracy],
:description => "Hi I’m David and I’m honoured to be your VP Democracy and Creative Industries for the coming year! My remit includes three key areas; ensuring we’ve got strong democratic processes, including exciting elections throughout the year, strengthening our already award-winning Union Films, Media and Performing Arts groups and helping student groups to develop further. There’s so much to do within the Union and hopefully I can help you to achieve some of your aims!",
)

Zone.destroy_all
trustee = Zone.create(:name => "Trustee",
Expand Down

0 comments on commit 914de94

Please sign in to comment.