From: Date: Mon, 27 Aug 2007 23:02:32 +0000 (-0400) Subject: Created a user "summary/profile page". Also corected several minor typos on election... X-Git-Url: https://projects.mako.cc/source/selectricity/commitdiff_plain/796d33df26fa2f591a405810ae4958a26cf060a4 Created a user "summary/profile page". Also corected several minor typos on election results pages. Modified the sign-up page to be more informative. --- diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index bb614de..e8adcf0 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -10,7 +10,9 @@ class AccountController < ApplicationController def index redirect_to(:action => 'signup') unless logged_in? || User.count > 0 end - + + #these methods provide basic functionality for the user login system + #=================================================================== def login return unless request.post? self.current_user = User.authenticate(params[:login], params[:password]) @@ -42,4 +44,14 @@ class AccountController < ApplicationController flash[:notice] = "You have been logged out." redirect_back_or_default(:controller => '/site', :action => 'index') end + #====================================================================== + + #The following methods are for slectricity specific uses + def summary + @user = User.find(params[:id]) + end + + end + + diff --git a/app/controllers/application.rb b/app/controllers/application.rb index 23c878f..9b48030 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -6,5 +6,4 @@ class ApplicationController < ActionController::Base helper :user require_dependency "user" - end diff --git a/app/controllers/election_controller.rb b/app/controllers/election_controller.rb index 7040c38..4ad8bac 100644 --- a/app/controllers/election_controller.rb +++ b/app/controllers/election_controller.rb @@ -67,6 +67,15 @@ class ElectionController < ApplicationController @election.activate! redirect_to :action => 'show', :id => @election.id end + + def change_notices + election = Election.find(params[:id]) + if election.notices == 0 + election.notices = 1 + else + election.notices = 0 + end + end # methods fod display, adding, deleting, and manipulating candidate # information for elections diff --git a/app/controllers/quickvote_controller.rb b/app/controllers/quickvote_controller.rb index 7ad1722..cd63c2e 100644 --- a/app/controllers/quickvote_controller.rb +++ b/app/controllers/quickvote_controller.rb @@ -17,6 +17,8 @@ class QuickvoteController < ApplicationController @quickvote.description=@quickvote.description #record who created the quickvote so that person can monitor it easily @quickvote.quickuser = session.session_id + #Give registered users additional QuickVote functionality + @quickvote.user_id = session[:user][:id] if session[:user] # try to save, if it fails, show the page again (the flash should # still be intact if @quickvote.save diff --git a/app/views/account/signup.rhtml b/app/views/account/signup.rhtml index c0012a7..f5228d8 100644 --- a/app/views/account/signup.rhtml +++ b/app/views/account/signup.rhtml @@ -1,10 +1,13 @@ <%= error_messages_for :user %> <% form_for :user do |f| -%> +


<%= f.text_field :login %>


-<%= f.text_field :email %>

+<%= f.text_field :email %>
+People participating in elections you're administrating will contact you +at this address.


<%= f.password_field :password %>

diff --git a/app/views/account/summary.rhtml b/app/views/account/summary.rhtml new file mode 100644 index 0000000..2f24e28 --- /dev/null +++ b/app/views/account/summary.rhtml @@ -0,0 +1,84 @@ +

This is your user summary profile, <%=h @user.login.capitalize %>

+ +

+E-mail: <%=h @user.email %>
+Member since: <%=h @user.created_at.strftime("%x") %> +

+ +

Your Elections: + + + <% Election.content_columns.each do |column| -%> + <% next if column.name.eql?("viewable") || column.name.eql?("quickuser")\ + || column.name.eql?("active") %> + + <% end -%> + + + <% @user.elections.select {|e| e.instance_of?(Election)}.each do |election| %> + + + + + + + + + + <% end -%> +
<%= column.human_name %>
+ <% if election.active == 1 -%> + <%= link_to "#{election.name}", :controller => 'election', + :action => 'show', :id => election %> + <% else -%> + <%=h election.name %> + <% end -%> + <%=h election.description %> + <% if election.anonymous == 0 -%> + No + <% else -%> + Yes + <% end -%> + <%=h election.startdate.strftime("%x") %><%=h election.enddate.strftime("%x") %> + <% if election.notices == 0 -%> + No + <% else -%> + Yes + <% end -%> + <%=h election.election_method %>
+

+ +

+Your Quickvotes: + + + <% ["Name", "Description", "Start Date", "End Date", "Notices"].each do |column| %> + + <% end -%> + + + <% @user.elections.select {|e| e.instance_of?(QuickVote)}.each do |quickvote| + %> + + + + + + + +<% end %> +
<%= column %>
+ <% if quickvote.active == 1 %> + <%= link_to "#{quickvote.name}", + quickaction_url( :ident => quickvote.name, + :action => 'results' ) %> + <% else %> + <%=h quickvote.name %> + <% end %> + <%=h quickvote.description %><%=h quickvote.startdate.strftime("%x") %><%=h quickvote.enddate.strftime("%x") %> + <% if quickvote.notices == 0 -%> + No + <% else -%> + Yes + <% end -%> +
diff --git a/app/views/election/show.rhtml b/app/views/election/show.rhtml index ff06521..5d22f44 100644 --- a/app/views/election/show.rhtml +++ b/app/views/election/show.rhtml @@ -34,7 +34,7 @@ <% end %>

Candidates

- +<% %> <% unless @election.candidates.empty? %> <%= render :partial => 'candidate_list' %> <% unless @election.active %> @@ -65,7 +65,7 @@ <% end %> <% else %> -

Please check eveything carefully on this page before starting this +

Please check everything carefully on this page before starting this vote. Once you begin the vote, you will not be able to add or change candidates, modify the voting lists, or change the end time.

diff --git a/app/views/layouts/main.rhtml b/app/views/layouts/main.rhtml index 027ef14..0ed6082 100644 --- a/app/views/layouts/main.rhtml +++ b/app/views/layouts/main.rhtml @@ -19,7 +19,10 @@