+ + + + diff --git a/app/views/spam_messages/show_revise.html.erb b/app/views/spam_messages/show_revise.html.erb index 0b656bc..20e2185 100644 --- a/app/views/spam_messages/show_revise.html.erb +++ b/app/views/spam_messages/show_revise.html.erb @@ -11,7 +11,7 @@ <% elsif @spam_message.spam_status == SpamMessage::SPAM_STATUS::SPAM %> <%= link_to 'не спам', { :action => "revise_cancel_status", :id => @spam_message.id}, :confirm => 'Точно?' %> <% elsif @spam_message.spam_status == SpamMessage::SPAM_STATUS::REVISED_SPAM || @spam_message.spam_status == SpamMessage::SPAM_STATUS::REVISED_NOT_SPAM %> - nothing to do + nothing to do <% end -%>
diff --git a/config/asset_packages.yml b/config/asset_packages.yml index 10fcfed..d4416d2 100644 --- a/config/asset_packages.yml +++ b/config/asset_packages.yml @@ -11,3 +11,4 @@ stylesheets: - style_2 - user - funny_cards + - meetings diff --git a/config/routes.rb b/config/routes.rb index 0a37022..b55c7c8 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -3,6 +3,7 @@ ActionController::Routing::Routes.draw do |map| map.with_options :path_prefix => '/:locale' do |m| m.resources :products, :controller => "users/products" m.resources :news + m.resources :meetings, :collection => {:my_meetings => :get, :journal => :get, :show_photos => :get, :guests => :get} end map.with_options :path_prefix => '/:locale' do |m| diff --git a/db/migrate/141_create_meetings.rb b/db/migrate/141_create_meetings.rb new file mode 100644 index 0000000..605a886 --- /dev/null +++ b/db/migrate/141_create_meetings.rb @@ -0,0 +1,18 @@ +class CreateMeetings < ActiveRecord::Migration + def self.up + create_table :meetings do |t| + t.integer :user_id + t.string :name + t.text :description + t.string :location + t.string :city + t.string :email + t.datetime :start_at + t.datetime :end_at + end + end + + def self.down + drop_table :meetings + end +end diff --git a/db/migrate/142_create_participants.rb b/db/migrate/142_create_participants.rb new file mode 100644 index 0000000..55d7599 --- /dev/null +++ b/db/migrate/142_create_participants.rb @@ -0,0 +1,15 @@ +class CreateParticipants < ActiveRecord::Migration + def self.up + create_table :participants do |t| + t.integer :meeting_id + t.integer :user_id + t.integer :photo_album_id + t.integer :status + t.datetime :created_at + end + end + + def self.down + drop_table :participants + end +end diff --git a/public/stylesheets/meetings.css b/public/stylesheets/meetings.css new file mode 100644 index 0000000..d94b41c --- /dev/null +++ b/public/stylesheets/meetings.css @@ -0,0 +1,134 @@ +#meetingslist {background:#f7f7f7;padding:1px 10px 10px 10px;} +#meetingslist .meetingrow{background:white;padding:10px;border:1px solid #ccc;} +#meetingslist table{background:white;border-bottom:none;font-size:11px;} +#meetingslist table.editor{background:#f7f7f7;border-bottom:none;font-size:11px;} +#meetingslist .image{vertical-align:top;text-align:left;width:60px;} +#meetingslist .tunaimage{vertical-align:top;text-align:left;width:110px;} +#meetingslist .info{vertical-align:top;width:385px;} +#meetingslist .actions{vertical-align:top;width:100px;} +#meetingslist .actions a{display:block;margin:0px;padding:2px 4px;border-bottom:solid 1px #D8DFEA;} +#meetingslist .actions a:hover{color:white;background:#FF6600;text-decoration:none;} +#meetingslist .eventtitle{padding:0 5px 10px 0;} +#meetingslist .eventtitle h3{font-size:12px;} +#meetingslist .eventtitle p{margin:2px 0 0 0;color:gray;font-size:9px;} +#meetingslist .infotable .label{color:gray;width:80px;padding-bottom:2px;vertical-align:top;} +#meetingslist .infotable hr{border:none 0;border-top:1px solid #d8dfea;width:100%;height:1px;} +#meetingslist .meetingrow .eventdivider{border:none 0;border-top:1px solid #d8dfea;width:100%;height:1px;margin-top:-5px;padding-bottom:5px;} +#meetingslist .timeline{text-align:left;color:#333;padding:3px 10px;font-weight:bold;font-size:11px;background:#e7e7e7;margin:10px 0 0 0;} + +.clearfix:after{content:".";display:block;clear:both;visibility:hidden;line-height:0;height:0;} +.clearfix{display:inline-block;} +html[xmlns] .clearfix{display:block;} +* html .clearfix{height:1%;} + + +#tabs{text-align:center;padding:4px 0px;margin:10px 20px 0px;border-bottom:solid 1px #3B5998;} +#tabs div{display:inline;padding:0px;margin:0px;} +#tabs div{margin:0 3px;} +#tabs a{margin:0px;padding:4px;} +#tabs .activetab a{color:white;background:#FF7733;} +#tabs .activetab a:hover{text-decoration:none;} +#tabs .inactivetab a:hover{background:#D8DFEA;text-decoration:none;} +#tabs .disabled{color:#c0c0c0;margin:0px;padding:4px;text-decoration:none;} +.tabs{padding:3px 0;border-bottom:1px solid #898989;} +.tabs.top{background:#f7f7f7;} +.tabs .left_tabs{padding-left:10px;float:left;} +.tabs .right_tabs{padding-right:10px;float:right;} +.tabs .back_links{padding-right:20px;float:right;} +.toggle_tabs{margin:0;padding:0;list-style:none;text-align:center;display:inline;} +.toggle_tabs li{display:inline;padding:2px 0px 3px;background:#f1f1f1 url(/images/components/toggle_tab_gloss.gif) top left repeat-x;} +.toggle_tabs li a{border:1px solid #898989;border-left:0;color:#333;font-weight:bold;padding:2px 8px 3px 9px;} +.toggle_tabs li a small{font-size:11px;font-weight:normal;} +.toggle_tabs li a:focus{outline:0px;} +.toggle_tabs li.first a{border:1px solid #898989;} +.toggle_tabs li a.selected{margin-left:-1px;background:#6d84b4;border:1px solid #3b5998;border-left:1px solid #5973a9;border-right:1px solid #5973a9;color:#fff;} +.toggle_tabs li.last a.selected{margin-left:-1px;border-left:1px solid #5973a9;border-right:1px solid #36538f;} +.toggle_tabs li.first a.selected{margin:0;border-left:1px solid #36538f;border-right:1px solid #5973a9;} +.toggle_tabs li.first.last a.selected{border:1px solid #36538f;} +.toggle_tabs li a.selected:hover{text-decoration:none;} +.toggle_tabs li a.disabled{color:#999;cursor:default;} +.toggle_tabs li a.disabled:hover{text-decoration:none;} + +#event.profile .right .header{clear:both;} +#rsvp_status_text{color:gray;font-weight:bold;margin:0px;padding:0px 0px 5px 0px;} +#rsvp_form div.rsvp_option{padding:2px 0px 3px 4px;} +#rsvp_form .inputradio{margin-right:5px;} +#rsvp_form label{color:black;font-weight:normal;} +#rsvp_form #rsvp{margin:8px 0px 0px 2px;} + +.editor{margin:3px auto 7px;} +.editor_panel{background:#f7f7f7;padding:10px 0px;} +.editor td{border:none;margin:0px;padding:5px 1px 1px;} +.editor td.label{color:#666;font-weight:bold;padding-right:10px;} +.editor td.label small{color:#999;} +.editor .suboption_group{border-bottom:1px solid #c0c0c0;border-top:1px solid #c0c0c0;margin-left:20px;} +.editor .suboption_group td{padding:0px;} +.editor tr.tallrow{vertical-align:top;} +.editor tr.tallrow td.label{padding-top:7px;} +.editor tr.subrow{vertical-align:top;} +.editor tr.subrow td{margin-top:0px;padding-top:0px;} +.editor .buttons{padding:10px 0px 0px;text-align:center;} +.editor .buttons_left{padding-left:0px;text-align:left;} +.editor .buttons .inputsubmit, +.editor .buttons .inputbutton{margin:2px 4px;} +.editor .buttons_left .inputsubmit, +.editor .buttons_left .inputbutton{margin-left:0px;} +.editor label{color:black;font-weight:normal;width:200px;} +.editor table.option_field td{margin:0px;padding:0px 2px 0px 0px;} +.editor .option_caption{color:#777;font-weight:normal;padding-bottom:2px;width:260px;} +.editor .inputtext, +.editor .inputpassword{margin-left:0px;width:300px;} +.editor textarea{margin-left:0px;width:300px;} +.editor select{margin-left:0px;margin-right:5px;} +.editor .checkbox_array{margin:0px;padding:5px 0px 0px;} +.editor .checkbox_array td{margin:0px;padding:0px 0px 0px;} +.editor .checkbox_array label{padding-right:15px;} +.editor .relationship .inputtext{width:200px;} +.editor .highschool input{margin-right:5px;width:235px;} +.editor .school input{margin-right:5px;width:235px;} +.editor .select xselect{width:200px;} +.editor .two_level_select select{width:145px;} +.editor .text_with_privacy input{margin-right:5px;width:105px;} +.editor .text_with_privacy select{margin-left:5px;width:auto;} +.editor .text_with_privacy td{color:#777;} +.editor .divider{border-bottom:solid 1px #fff;border-top:solid 1px #ccc;height:0px;margin:5px 0px;overflow:hidden;} +.editor .date_time span, .editor .inline_text{margin:0px 4px 0px -2px;} +.editor .note{width:300px;} +.editor .hiddenrow{display:none;} +.editor .calendar_popup{display:inline;} +.editor .calendar_at_time{padding:0px 0px 0px 8px;} +.editor .calicon{padding:0px 2px 1px 0px;} +.editor .calendars td{padding:0px;} +.editor #start_calendar, .editor #end_calendar{background-color:#fff;border-bottom:solid 1px #3b5998;border-left:solid 1px #d8dfea;border-right:solid 1px #d8dfea;margin-left:147px;margin-top:-3px;position:absolute;width:168px;z-index:100;} +.editor #box_separator{padding:0px 3px 0px 3px;} + +.title_header{background:white;padding:20px 20px 17px;} +.title_header h2{margin:0px;font-size:14px;padding:0px 0px 0px 24px;background:url(/images/icons/hidden.gif) no-repeat 1px 1px;} +.title_header h2.no_icon{padding:0px;background:none;} +.title_header.add_border{border-bottom:solid 1px #ccc;} +.title_header.gray{background:#f7f7f7;} +.title_header.shorten{padding-bottom:0px;} +.title_header.no_padding{padding:0px;} +.title_header h4{color:#666;font-size:11px;font-weight:normal;padding:3px 0 0 24px;} +.title_header h4.no_icon{padding:3px 0 0 0;} + +.formbuttons{text-align:center;margin:10px 10px;} +.formbuttons .inputsubmit, .formbuttons .inputbutton{margin:2px 4px;} +.formbuttons .securetoggle{padding:9px 0px 0px 0px;} +.inputtext, +.inputpassword{border:1px solid #bdc7d8;font-family:"lucida grande", tahoma, verdana, arial, sans-serif;font-size:11px;padding:3px;} + +.inputbutton, +.inputsubmit{padding:2px 15px 3px 15px;border-style:solid;border-top-width:1px;border-left-width:1px;border-bottom-width:1px;border-right-width:1px;border-color:#D9DFEA #0E1F5B #0E1F5B #D9DFEA;background-color:#FF7733;color:#FFFFFF;font-size:11px;font-family:"lucida grande", tahoma, verdana, arial, sans-serif;text-align:center;} +.inputaux{background:#f0f0f0;color:#000;border-top-color:#e7e7e7;border-right-color:#666;border-bottom-color:#666;border-left-color:#e7e7e7;} + +.column{float:left;} +.bar .events_bar{color:#333;padding:5px 20px;} + +.inputcheckbox{border:0px;} + +.userlist{padding:3px;line-height:20px;width:183px;height:100px;overflow:auto;background:#fff;border:1px solid #D8DFEA;} + +.filter_form{padding:5px 0px 7px;} +.filter_form label{display:block;margin:0px 0px 4px;} +.filter_form input{margin:0px;width:183px;} diff --git a/public/stylesheets/style_2.css b/public/stylesheets/style_2.css index ac72242..b9a74ea 100644 --- a/public/stylesheets/style_2.css +++ b/public/stylesheets/style_2.css @@ -1485,7 +1485,7 @@ border: 1px solid #000000; .album { width: 172px; height: 173px; - dxisplay:block; + display:block; padding: 10px 0 0 0; margin: 0; background-image: url(/images/album.gif); diff --git a/test/fixtures/meetings.yml b/test/fixtures/meetings.yml new file mode 100644 index 0000000..9bad144 --- /dev/null +++ b/test/fixtures/meetings.yml @@ -0,0 +1,22 @@ +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html + +one: + user_id: 1 + location: Earth + description: Will be fine + start_at: 2008-06-02 13:27:28 + created_at: 2008-06-02 13:27:28 + +two: + user_id: 2 + location: un loc bun + description: merita de dus + start_at: 2008-06-02 13:27:28 + created_at: 2008-06-02 13:27:28 + +three: + user_id: 3 + location: Location 3 + description: pentru cei ce stiu + start_at: 2008-06-02 13:27:28 + created_at: 2008-06-02 13:27:28 \ No newline at end of file diff --git a/test/functional/meetings_controller_test.rb b/test/functional/meetings_controller_test.rb new file mode 100644 index 0000000..77b7929 --- /dev/null +++ b/test/functional/meetings_controller_test.rb @@ -0,0 +1,50 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class MeetingsControllerTest < ActionController::TestCase + def test_should_get_index + get :index + assert_response :success + assert_not_nil assigns(:meetings) + end + + def test_should_get_new + login_bob + get :new + assert_response :success + end + + def test_should_create_meeting + login_bob + assert_difference('Meeting.count') do + post :create, :meeting => { } + end + + assert_redirected_to meeting_path(assigns(:meeting)) + end + + def test_should_show_meeting + get :show, :id => meetings(:one).id + assert_response :success + end + + def test_should_get_edit + login_bob + get :edit, :id => meetings(:one).id + assert_response :success + end + + def test_should_update_meeting + login_bob + put :update, :id => meetings(:one).id, :meeting => { } + assert_redirected_to meeting_path(assigns(:meeting)) + end + + def test_should_destroy_meeting + login_bob + assert_difference('Meeting.count', -1) do + delete :destroy, :id => meetings(:one).id + end + + assert_redirected_to meetings_path + end +end diff --git a/test/unit/meeting_test.rb b/test/unit/meeting_test.rb new file mode 100644 index 0000000..ce10a6b --- /dev/null +++ b/test/unit/meeting_test.rb @@ -0,0 +1,8 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class MeetingTest < ActiveSupport::TestCase + # Replace this with your real tests. + def test_truth + assert true + end +end

			
commit 0037553141938d69dfd95e282af42c7821144f03
Author: Kushnir Andrei 
Date:   Sat Sep 6 23:23:38 2008 +0300

    new feature: Meetings

diff --git a/app/controllers/application.rb b/app/controllers/application.rb
index c6fc766..a0cea38 100644
--- a/app/controllers/application.rb
+++ b/app/controllers/application.rb
@@ -96,6 +96,10 @@ protected
   def is_editor?
     logged_in? && current_user.user_status >= User::STATUS::EDITOR
   end
+  
+  def is_obj_owner? obj
+    logged_in? && (obj.user_id == current_user.id)
+  end
 
   def msg_private_network_on?
     current_user.char.msg_private_network_only == true 
diff --git a/app/controllers/meetings_controller.rb b/app/controllers/meetings_controller.rb
new file mode 100644
index 0000000..a033fba
--- /dev/null
+++ b/app/controllers/meetings_controller.rb
@@ -0,0 +1,241 @@
+class MeetingsController < ApplicationController
+  before_filter :login_required, :except => [:index]
+  helper :calendar
+  # GET /meetings
+  # GET /meetings.xml
+  def index
+    @title = "Встречи - Все записи"
+    @pages, @meetings = paginate :meetings,
+      :order => 'start_at desc', :per_page => 10
+
+    @right_part = :meetings_calendar
+    prepare_comment_count(@meetings, Comment::WHERE::MEETING)
+    
+    respond_to do |format|
+      format.html # index.html.erb
+      format.xml  { render :xml => @meetings }
+    end
+  end
+  
+  def my_meetings
+    @right_part = :meetings_calendar
+    @title = "Мои Встречи"
+    @pages, @meetings = paginate :meetings,
+      :conditions => 'user_id=' + current_user.id.to_s,
+      :order => 'start_at desc', :per_page => 10
+    prepare_comment_count(@meetings, Comment::WHERE::MEETING)
+  end
+
+  # GET /meetings/1
+  # GET /meetings/1.xml
+  def show
+    @right_part = :meetings_calendar
+    @meeting = Meeting.find(params[:id])
+    @current_participant = Participant.find :first, :conditions => ['user_id = ? and meeting_id = ?', current_user.id, @meeting.id]
+    @participants = @meeting.participants.find :all, :order => 'created_at asc' 
+    #@participants = Participant.find(:all, :conditions => 'meeting_id=' + @meeting.id.to_s, :order => 'start_at asc')
+    paginate_comments @meeting, Comment::WHERE::MEETING
+    respond_to do |format|
+      format.html # show.html.erb
+      format.xml  { render :xml => @meeting }
+    end
+  end
+  
+  def journal
+    redirect_to meetings_path
+  end
+  
+  # GET /meetings/new
+  # GET /meetings/new.xml
+  def new
+    @meeting = Meeting.new
+    @meeting_page == "event_info"
+    @title = "Новая встреча"
+    respond_to do |format|
+      format.html # new.html.erb
+      format.xml  { render :xml => @meeting }
+    end
+  end
+
+  # GET /meetings/1/edit
+  def edit
+    @meeting = Meeting.find(params[:id])
+    @title = "Редактировать мероприятие: "+ @meeting.name.to_s
+    @meeting_page = "edit_info"
+  end
+
+  # POST /meetings
+  # POST /meetings.xml
+  def create
+    @meeting = Meeting.new(params[:meeting])
+    @meeting.user_id = current_user.id
+    respond_to do |format|
+      if @meeting.save
+        @participant = Participant.new( :user_id => current_user.id)
+        @participant.status = Participant::PLAN::YES
+        @participant.join_meeting @meeting
+        flash[:notice] = 'Информация о Вашей встрече была сохранена.'
+        format.html { redirect_to(meeting_path(:id => @meeting)) }
+        format.xml  { render :xml => @meeting, :status => :created, :location => @meeting }
+      else
+        format.html { render :action => "new" }
+        format.xml  { render :xml => @meeting.errors, :status => :unprocessable_entity }
+      end
+    end
+  end
+
+  # PUT /meetings/1
+  # PUT /meetings/1.xml
+  def update
+    @meeting = Meeting.find(params[:id])
+#   @meeting.user_id == current_user.id || is_moderator?
+    if is_obj_owner? @meeting
+      respond_to do |format|
+        if @meeting.update_attributes(params[:meeting])
+          @meeting_page = "edit_info"    
+          flash[:notice] = 'Информация о Вашей встрече была обновлена.'
+          format.html { render :action => "edit" }
+          format.xml  { head :ok }
+        else
+          @meeting_page = "edit_info"
+          format.html { render :action => "edit" }
+          format.xml  { render :xml => @meeting.errors, :status => :unprocessable_entity }
+        end
+      end
+    else
+      render :text => 'no'
+    end 
+  end
+  
+  def add_comment
+    @meeting = Meeting.find(params[:id])
+    add_obj_comment @meeting, Comment::WHERE::MEETING
+    redirect_to :action => "show", :id => @meeting.id
+  end
+  
+  def change_participant_status
+    @meeting = Meeting.find(params[:id])
+    @participant = Participant.find :first, 
+    :conditions => ['meeting_id = ? and user_id = ?', @meeting.id, current_user.id]
+    if @participant
+      @participant.status = params[:current_participant][:status]
+      @participant.save
+      redirect_to :action => "show", :id => @meeting.id
+    else
+      @meeting = Meeting.find(params[:id])
+      @participant = Participant.new( :user_id => current_user.id)
+      @participant.status = params[:current_participant][:status]
+      @participant.join_meeting @meeting
+      redirect_to :action => "show", :id => @meeting.id
+    end
+  end
+  
+  def edit_settings
+    @title = "Настроить параметры встречи"
+    @meeting = Meeting.find(params[:id])
+    @meeting_page = "edit_settings"
+    render :action => 'edit'
+  end
+
+  
+  def add_guests
+    @title = "Пригласить гостей "
+    @meeting = Meeting.find(params[:id])
+    @my_friends = MyFriend.find :all, :conditions => ['user_id = ?', current_user.id]
+
+    @meeting_page = "edit_guests"
+    render :action => 'edit'
+  end
+  
+  def add_photos
+    @photo_album = PhotoAlbum.new
+    @meeting = Meeting.find(params[:id])
+    @participant = Participant.find_by_user_id(current_user.id)
+    if request.post?
+      @photo_album.attributes = params[:photo_album]
+      @photo_album.user_id = current_user.id
+#      category_id = 8 for "Встречи"
+      @photo_album.category_id = 8
+      @photo_album.location = @meeting.location
+      if @photo_album.save
+        save_photos
+        @participant.update_participants_photo_album(@photo_album, @meeting)
+        flash[:notice] = 'Альбом был успешно сохранен.'._
+        redirect_to photo_album_url(:id => @photo_album)
+      else
+        render :action => 'add_photos'
+      end
+    end
+  end
+  
+  
+  def show_photos
+    @title = "Фото"._
+    cond = ['1 = 1']
+    @title1 = ''
+    @category_id = 8
+
+    if UserPhoto::CATEGORIES.has_key?(@category_id) && @category_id > 0
+      cond[0] += ' AND photo_albums.category_id = ?'
+      cond << @category_id
+    end
+
+    PhotoAlbum.public_scope do
+      @pages, @photos = paginate :photo_albums,
+        :conditions => cond,
+        :include => [:user, :cover_photo],
+        :order => 'photo_albums.taken_at desc', :per_page => 24
+    end
+    render :template => 'meetings/photos'
+  end
+
+
+  # DELETE /meetings/1
+  # DELETE /meetings/1.xml
+  def delete_meeting
+    @meeting = Meeting.find(params[:id])
+    @participants = Participant.find(:all, :conditions => 'meeting_id=' + @meeting.id.to_s)
+    if is_obj_owner?(@meeting) || is_moderator?
+      @meeting.destroy
+      for participant in @participants
+        participant.destroy
+      end
+      respond_to do |format|
+       format.html { redirect_to :action => :my_meetings }
+       format.xml  { head :ok }
+      end
+    else
+      render :text => 'no'
+    end    
+  end
+
+private
+
+  def save_photos
+  1.upto(5) do |i|
+    if !params["photo#{i}"].blank?
+      @photo = UserPhoto.new params["photo#{i}"]
+      @photo.user_id = current_user.id
+      @photo.category_id = 0
+      @photo.photo_album = @photo_album
+      @photo.moderate_status = UserPhoto::MODERATE_STATUS::AUTO_ACCEPTED if special_photo_user(current_user)
+
+      if @photo.save
+        flash[:notice] = "Фотографии добавлены"._
+      else
+        logger.debug "c-type:#{@photo.content_type}"
+      end
+    end
+  end
+  end
+  
+  def send_checked_guests_notification(guest_id_array)
+    checked_guests = []
+    checked_params = params[:guest_list] || []
+    for check_box_id in checked_params
+      guest = User.find(check_box_id)
+    end
+    return checked_guests
+  end
+  
+end
diff --git a/app/helpers/meetings_helper.rb b/app/helpers/meetings_helper.rb
new file mode 100644
index 0000000..de8cd78
--- /dev/null
+++ b/app/helpers/meetings_helper.rb
@@ -0,0 +1,11 @@
+module MeetingsHelper
+  
+  def is_active_tab? current_action
+    if current_page?(:action => current_action)
+      "activetab"
+    else
+      "inactivetab"
+    end
+  end
+  
+end
diff --git a/app/models/comment.rb b/app/models/comment.rb
index d6d9357..6a2f3c3 100644
--- a/app/models/comment.rb
+++ b/app/models/comment.rb
@@ -43,6 +43,7 @@ class Comment < ActiveRecord::Base
     VIDEO_LINK, PAID_NEWS = 5, 6
     SURVEY = 7
     HATE_CASE = 8
+    MEETING= 9
   end
   
   def relations
@@ -54,7 +55,8 @@ class Comment < ActiveRecord::Base
       WHERE::VIDEO_LINK => [Event::OBJ_TYPE::VIDEO_LINK, VideoLink],
       WHERE::PAID_NEWS => [Event::OBJ_TYPE::PAID_NEWS, PaidNews],
       WHERE::SURVEY => [Event::OBJ_TYPE::SURVEY, Survey],
-      WHERE::HATE_CASE => [Event::OBJ_TYPE::HATE_CASE, HateCase]
+      WHERE::HATE_CASE => [Event::OBJ_TYPE::HATE_CASE, HateCase],
+      WHERE::MEETING => [Event::OBJ_TYPE::MEETING, Meeting]
     }
   end
 end
diff --git a/app/models/event.rb b/app/models/event.rb
index 467449b..68bb84e 100644
--- a/app/models/event.rb
+++ b/app/models/event.rb
@@ -12,6 +12,7 @@ class Event < ActiveRecord::Base
     PAID_NEWS = 100
     BIRTHDAY = 110
     HATE_CASE = 120
+    MEETING = 130
   end
 
   OBJ_TYPE_H = { OBJ_TYPE::GROUP => "Клану",
@@ -20,7 +21,8 @@ class Event < ActiveRecord::Base
                  OBJ_TYPE::NEWS => "Новости",
                  OBJ_TYPE::SURVEY => "Опросу",
                  OBJ_TYPE::HATE_CASE => "Заявка",
-                 OBJ_TYPE::NOTE => "Дневнику"
+                 OBJ_TYPE::NOTE => "Дневнику",
+                 OBJ_TYPE::MEETING => "Встрече"
   }
 
   class TYPE
diff --git a/app/models/meeting.rb b/app/models/meeting.rb
new file mode 100644
index 0000000..cc64bd5
--- /dev/null
+++ b/app/models/meeting.rb
@@ -0,0 +1,13 @@
+class Meeting < ActiveRecord::Base
+  has_many :comments, :foreign_key => '_for', :conditions => '_where = ' + Comment::WHERE::MEETING.to_s,
+          :dependent => :delete_all, :order => 'created_at'
+
+  belongs_to :user
+  has_many  :participants
+  validates_presence_of :name, :location, :city, :description, :start_at
+  
+  def has_participant? user
+    Participant.find :first, :conditions => ['meeting_id=? and user_id=?', self.id, user.id]
+  end
+
+end
diff --git a/app/models/participant.rb b/app/models/participant.rb
new file mode 100644
index 0000000..c749d6c
--- /dev/null
+++ b/app/models/participant.rb
@@ -0,0 +1,49 @@
+class Participant < ActiveRecord::Base
+  has_many    :meetings
+  has_many    :photo_albums
+  belongs_to  :user
+  validates_presence_of :user_id, :meeting_id
+#  validates_uniqueness_of :user_id, :scope => [:photo_album_id]
+  
+  def join_meeting meeting
+    self.meeting_id = meeting.id
+    self.save
+  end
+  
+  def is_participant? meeting
+    if Participant.find_by_id(current_user.id, :conditions => 'meeting_id=' + meeting.id.to_s)
+      true
+    else
+      false
+    end
+  end
+  
+  def update_participants_photo_album(album, meeting)
+    p = Participant.find_by_user_id(self.user_id,:conditions => "photo_album_id is null")
+    if !p.nil?
+      self.photo_album_id = album.id
+      self.save
+    elsif p.nil?
+      Participant.new(:user_id => self.user_id, :photo_album_id => album.id, :meeting_id => meeting.id)
+      self.save
+   end
+  end
+  
+  class PLAN
+    NO = 0
+    YES = 1
+    MAYBE = 2
+    PENDING = 3
+  end
+  
+  PLAN_A = [
+    ["пойду", PLAN::YES],
+    ["не пойду", PLAN::NO],
+    ["возможно пойду", PLAN::MAYBE],
+    ["еще не ответил", PLAN::PENDING]
+  ]
+  
+  PLAN_H = PLAN_A.to_hash2
+  
+end
+
diff --git a/app/models/user.rb b/app/models/user.rb
index 746cc2d..7708379 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -70,6 +70,7 @@ class User < ActiveRecord::Base
   has_many :surveys, :dependent => :delete_all
   has_many :notifications, :dependent => :delete_all
   has_many  :sent_notifications, :class_name => 'Notification', :foreign_key => 'sender_id', :dependent => :delete_all
+  has_many :meetings
 
   def is_seller?
     user_caracter.is_seller? == true
diff --git a/app/models/user_photo.rb b/app/models/user_photo.rb
index 870b3bd..761febd 100644
--- a/app/models/user_photo.rb
+++ b/app/models/user_photo.rb
@@ -136,6 +136,7 @@ class UserPhoto < ActiveRecord::Base
     ["Май Фамили", 5],
     ["Отдыхаем", 6],
     ["Афтор Жжжооот", 7],
+    ["Встречи", 8]
   ]
 
   CATEGORIES = to_hash(CATEGORIES_A)
diff --git a/app/views/layouts/_top_menu.rhtml b/app/views/layouts/_top_menu.rhtml
index 71e1eeb..e1c591c 100644
--- a/app/views/layouts/_top_menu.rhtml
+++ b/app/views/layouts/_top_menu.rhtml
@@ -9,6 +9,7 @@
     <%= link_to "Фотки"._, all_photos_path %>
     <%= link_to "Видео"._, videos_path %>
     <%= link_to "Кланы"._, search_groups_path %>
+    <%= link_to "Встречи"._, meetings_path %>
     <%= link_to "Маркет"._, market_path %>
     <%= link_to "Поиск"._, search_what_path %>
 
diff --git a/app/views/layouts/_user_panel.rhtml b/app/views/layouts/_user_panel.rhtml
index de38e3f..2d0e83b 100644
--- a/app/views/layouts/_user_panel.rhtml
+++ b/app/views/layouts/_user_panel.rhtml
@@ -35,6 +35,12 @@
 <%=link_to 'Видео'._, {:controller => "/my_videos"}, :class => 'user_links' %>
                   
<%= my_panel_icon('04_diery.gif') %> +<%=link_to 'Встречи'._, {:action => "my_meetings", :controller => "/meetings"}, :class => 'user_links' %> +
<%= my_panel_icon('klan.gif') %> diff --git a/app/views/layouts/application.rhtml b/app/views/layouts/application.rhtml index 79794c4..538005a 100644 --- a/app/views/layouts/application.rhtml +++ b/app/views/layouts/application.rhtml @@ -114,6 +114,8 @@ if flash.has_key?(:error) %> <% if @right_part == :calendar %> <%= render :partial => 'users/journal_calendar' %> + <% elsif @right_part == :meetings_calendar %> + <%= render :partial => 'meetings/meeting_calendar' %> <% elsif @right_part == :photos %> <%= render :partial => 'users/photos_calendar' %> <% elsif @right_part == :album %> diff --git a/app/views/meetings/_edit_guests.html.erb b/app/views/meetings/_edit_guests.html.erb new file mode 100644 index 0000000..cdcf899 --- /dev/null +++ b/app/views/meetings/_edit_guests.html.erb @@ -0,0 +1,30 @@ +<%= error_messages_for :meeting %> +<% form_for(:meeting, :url => meeting_path(:id => @meeting), + :html => { :method => :put }) do |f| %> + + + + + + + + + + + +
Пригласить друзей :<%= text_field :name, :class => "inputtext"%>
+
+ <% for my_friend in @my_friends %> + <%= check_box_tag('guest_list[]', my_friend.friend_id, + @my_friends.collect {|obj| obj.id}.include?(my_friend.friend_id), :class => "inputcheckbox")%> +
+ <% end %> +
+
+
+ <%= f.submit "Отправить приглашения", :class => "inputbutton" %> + <%= submit_tag "Вернутся к событию", :class => "inputbutton ", :id => @meeting.id %> +
+
+ +<% end %> diff --git a/app/views/meetings/_edit_info.html.erb b/app/views/meetings/_edit_info.html.erb new file mode 100644 index 0000000..b25b4f6 --- /dev/null +++ b/app/views/meetings/_edit_info.html.erb @@ -0,0 +1,43 @@ +<%= error_messages_for :meeting %> +<% form_for(:meeting, :url => meeting_path(:id => @meeting), + :html => { :method => :put }) do |f| %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Название мероприятия:
(обязательно)
<%= f.text_field :name, :class => "inputtext" %>
 
Описание:<%= f.text_area :description %>
Время начала: <%= f.datetime_select :start_at %>
Время завершения: <%= f.datetime_select :end_at %>
 
Место проведения:
(обязательно)
<%= f.text_field :location, :class => "inputtext" %>
Город:
(обязательно)
<%= f.text_field :city, :class => "inputtext" %>
 
+
+ <%= f.submit "Сохранить изменения", :class => "inputbutton" %> + <%= submit_tag "Вернутся к событию", :class => "inputbutton ", :id => @meeting.id %> +
+
+ +<% end %> \ No newline at end of file diff --git a/app/views/meetings/_edit_settings.html.erb b/app/views/meetings/_edit_settings.html.erb new file mode 100644 index 0000000..a496487 --- /dev/null +++ b/app/views/meetings/_edit_settings.html.erb @@ -0,0 +1,6 @@ +<%# +# To change this template, choose Tools | Templates +# and open the template in the editor. +%> + +<%= "_customize.html" %> diff --git a/app/views/meetings/_form.html.erb b/app/views/meetings/_form.html.erb new file mode 100644 index 0000000..59a9de8 --- /dev/null +++ b/app/views/meetings/_form.html.erb @@ -0,0 +1,43 @@ +<%= error_messages_for :meeting %> + +<% form_for(@meeting) do |f| %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Название мероприятия:
(обязательно)
<%= f.text_field :name, :class => "inputtext" %>
 
Описание:<%= f.text_area :description %>
Время начала: <%= f.datetime_select :start_at %>
Время завершения: <%= f.datetime_select :end_at %>
 
Место проведения:
(обязательно)
<%= f.text_field :location, :class => "inputtext" %>
Город:
(обязательно)
<%= f.text_field :city, :class => "inputtext" %>
 
+
+ <%= f.submit "Сохранить изменения", :class => "inputbutton" %> + <%= submit_tag "Отмена", :class => "inputbutton ", :id => @meeting.id %> +
+
+<%= link_to 'Back', meetings_path %> +<% end %> diff --git a/app/views/meetings/_meeting_calendar.rhtml b/app/views/meetings/_meeting_calendar.rhtml new file mode 100644 index 0000000..ccc46ea --- /dev/null +++ b/app/views/meetings/_meeting_calendar.rhtml @@ -0,0 +1,24 @@ +<%= box_header %> +
+ <% year = Time.now.year + month = Time.now.month + if !params[:month].nil? + a = params[:month].split(/\_/) + if a.size > 0 + year = a[0].to_i + month = a[1].to_i + end + end %> + <%= calendar(:year => year, :month => month) do |date| + attr = {:valign => 'middle'} + attr[:class] = 'chosen_date' if date == @chosen_date + [link_to_if(date <= Time.now.to_date, date.day, {:action => 'journal', :month => "#{year}_#{month}", :date => date}), attr] + end %> + <% if year < Time.now.year || (year == Time.now.year && month < Time.now.month)%> + <%= link_to CalendarHelper::MONTHNAMES[month == 12 ? 1:month+1], :action => 'journal', :controller => '/meetings', :month => "#{month == 12 ? year+1:year}_#{month == 12 ? 1:month+1}" %> + <% end %> + <%= link_to CalendarHelper::MONTHNAMES[month == 1 ? 12:month-1], :action => 'journal', :controller => '/meetings', :month => "#{month == 1 ? year-1:year}_#{month == 1 ? 12:month-1}" %> +
+<%= box_footer %> + + diff --git a/app/views/meetings/_meetings.html.erb b/app/views/meetings/_meetings.html.erb new file mode 100644 index 0000000..7a80ff4 --- /dev/null +++ b/app/views/meetings/_meetings.html.erb @@ -0,0 +1,49 @@ +

» <%= @title %>

+ +<% for meeting in @meetings %> +
+
<%= meeting.start_at.to_s(:long) %>
+
+ + + + + + + + +
+ + + + + + + + + + + + + +

<%= link_to truncate(format_message(meeting.description),60) , :action => "show", :id => meeting %>

Организатор: + <%=link_to_profile meeting.user %> +
Категория:Поездки - + Поездка на природу +
Где: + <%= link_to meeting.location , :action => "show", :id => meeting %> +
Когда:<%= meeting.start_at.to_s(:long) %> по
<%= meeting.end_at.to_s(:long) %>
+
+ <% if meeting.user_id == current_user.id || is_moderator? %> + <%= link_to 'Редактировать событие', edit_meeting_path(:id => meeting) %> + <%=link_to "Отменить встречу", :action => "delete_meeting", :id => meeting.id, :confirm => 'Really?' %> + <% end %> +
+
+
+ <% end %> +<%= pagination_div(@pages, params) %> \ No newline at end of file diff --git a/app/views/meetings/_participants.html.erb b/app/views/meetings/_participants.html.erb new file mode 100644 index 0000000..415c146 --- /dev/null +++ b/app/views/meetings/_participants.html.erb @@ -0,0 +1,8 @@ +

Участники

+<% for participant in @participants %> +<%= link_to_profile participant.user%>
+<% end %> + +<% if @participants.blank? %> +Пока что нет участников +<% end %> diff --git a/app/views/meetings/_photos_form.html.erb b/app/views/meetings/_photos_form.html.erb new file mode 100644 index 0000000..42b6ad6 --- /dev/null +++ b/app/views/meetings/_photos_form.html.erb @@ -0,0 +1,19 @@ +<%= error_messages_for 'photo_album' %> + + +


+<%= text_field 'photo_album', 'title', :size => 70 %>

+ +


+<%= date_select 'photo_album', 'taken_at', :start_year => current_user.age.year, :end_year => Time.now.year %>

+ +


+<%= text_area 'photo_album', 'description', :size => "60x4" %>

+ +<%= hidden_field 'photo_album', 'location', :value => "some value" %> +<%= hidden_field 'photo_album', 'category_id', :value => "some value" %> + +


+ <%= select 'photo_album', 'privacy', PhotoAlbum::PRIVACY_A, {}, :style => 'width:200px;' %>

+ + diff --git a/app/views/meetings/add_photos.html.erb b/app/views/meetings/add_photos.html.erb new file mode 100644 index 0000000..6556890 --- /dev/null +++ b/app/views/meetings/add_photos.html.erb @@ -0,0 +1,13 @@ +<%= site_title "Добавить фотографии для встречи"._ %> + +<% form_tag({:action => 'add_photos'}, :multipart => true) do %> + <%= render :partial => 'photos_form' %> + + <%= render :partial => 'photo_albums/upload_form' %> + + <%= submit_tag "Создать"._, :onclick => " + if ($('photo_album_title').value.length == 0) { + $('photo_album_title').focus(); + return false;} + " %> <%= link_to 'Отмена'._, meetings_url %> +<% end %> diff --git a/app/views/meetings/edit.html.erb b/app/views/meetings/edit.html.erb new file mode 100644 index 0000000..ce1e979 --- /dev/null +++ b/app/views/meetings/edit.html.erb @@ -0,0 +1,23 @@ +
+
+

<%= @title%>

+
+ +
+
+
<%= link_to 'Информация о событии', edit_meeting_path(:id => @meeting.id)%>
+
<%= link_to 'Настройки', :action => :edit_settings, :id => @meeting.id%>
+
<%= link_to 'Список гостей', :action => :add_guests, :id => @meeting.id%>
+
+
+ +
+ <% if @meeting_page == "edit_info" %> + <%= render :partial => 'edit_info' %> + <% elsif @meeting_page == "edit_settings" %> + <%= render :partial => 'edit_settings' %> + <% elsif @meeting_page == "edit_guests" %> + <%= render :partial => 'edit_guests' %> + <% end %> +
+
\ No newline at end of file diff --git a/app/views/meetings/exit.html.erb b/app/views/meetings/exit.html.erb new file mode 100644 index 0000000..c00cd1d --- /dev/null +++ b/app/views/meetings/exit.html.erb @@ -0,0 +1,2 @@ +

Meetings#exit

+

Find me in app/views/meetings/exit.html.erb

diff --git a/app/views/meetings/index.html.erb b/app/views/meetings/index.html.erb new file mode 100644 index 0000000..8972091 --- /dev/null +++ b/app/views/meetings/index.html.erb @@ -0,0 +1 @@ +<%= render :partial => 'meetings' %> diff --git a/app/views/meetings/list.html.erb b/app/views/meetings/list.html.erb new file mode 100644 index 0000000..8ffdccd --- /dev/null +++ b/app/views/meetings/list.html.erb @@ -0,0 +1,2 @@ +

Meetings#list

+

Find me in app/views/meetings/list.html.erb

diff --git a/app/views/meetings/my_meetings.html.erb b/app/views/meetings/my_meetings.html.erb new file mode 100644 index 0000000..0f156f1 --- /dev/null +++ b/app/views/meetings/my_meetings.html.erb @@ -0,0 +1,27 @@ +

» <%='Мои Встречи'._%> (<%= @pages.item_count %>)

+<%= link_to "Добавить"._, :action => "new" %> +<% for meeting in @meetings %> +

+

+ + <%=link_to image_tag('icons/trash.gif', :alt => 'Удалить'._), {:action => "delete_meeting", :id => meeting}, :confirm => 'Уверены?'._ %> + + + <%= h(meeting.location) %> + (<%= show_date(meeting.start_at) %>) +

+

+ <%= format_message(meeting.description) %> +

+ +

+<% end %> + +

diff --git a/app/views/meetings/new.html.erb b/app/views/meetings/new.html.erb new file mode 100644 index 0000000..9d28f3d --- /dev/null +++ b/app/views/meetings/new.html.erb @@ -0,0 +1,24 @@ +
+
+

<%= @title%>

+
+ +
+
+
<%= link_to 'Шаг 1: Информация о событии', :action => "new" %>
+
<%= link_to 'Шаг 2: Настройки', :action => :edit_settings, :id => @meeting.id%>
+
<%= link_to 'Шаг 3: Список гостей', :action => :add_guests, :id => @meeting.id%>
+
+
+ +
+ <%= render :partial => 'form' %> + <%# if @meeting_page == "event_info" %> + <%#= render :partial => 'form' %> + <%# elsif @meeting_page == "edit_settings" %> + <%#= render :partial => 'edit_settings' %> + <%# elsif @meeting_page == "edit_guests" %> + <%#= render :partial => 'edit_guests' %> + <%# end %> +
+
diff --git a/app/views/meetings/photos.html.erb b/app/views/meetings/photos.html.erb new file mode 100644 index 0000000..6ff8638 --- /dev/null +++ b/app/views/meetings/photos.html.erb @@ -0,0 +1,47 @@ +<% if @photos.size > 0 %> + +
+ +<% @photos.in_groups_of(3) do |row| -%> + + <% for ph in row +album = ph +-%> + +<% end %> + +<% end %> +
+ <% if ph.nil? %> +   + <% else %> +
+ + + + + + + +
+ + <%= link_to album_cover_img(album), photo_album_url(:id => album) %>
+ <%= link_to h(truncate(album.title, 20)), photo_album_url(:id => album)%>
+ <%= md_date(album.taken_at) %>(<%= album.photo_count %>) +
+ <%= link_to h(truncate(ph.user.login, 13)), profile_url(:id => ph.user_id), :class => 'b ' + sex_class(ph.user.male?), + :onMouseOver=> "showUserInfoPopup(event, '#{'Загрузка...'._}', '#{url_for(:action => 'small_info', :controller => '/users', :id => ph.user_id)}');", + :onMouseOut=> "hideMsg();" + %> +
+
+ <% end %> +
+
+ +

+ +<%= pagination_div(@pages, params) %> +<% else %> +

<%='Нет фоток'._%>

+<% end %> \ No newline at end of file diff --git a/app/views/meetings/show.html.erb b/app/views/meetings/show.html.erb new file mode 100644 index 0000000..52690c6 --- /dev/null +++ b/app/views/meetings/show.html.erb @@ -0,0 +1,73 @@ +<%= link_to 'Вернуться назад'._ + '»', meetings_path %> +

+ Организатор: + <%=link_to_profile @meeting.user %> +

+

+ Место встречи: + <%=h @meeting.location %> +

+

+ Описание: + <%= format_message @meeting.description %> +

+

+ Время начала: + <%= @meeting.start_at.to_s(:short) %> +

+

+ Время завершения: + <%= @meeting.end_at.to_s(:short) %> +

+ +<%if logged_in?%> +

Ваши планы на участие

+
+ <% form_for :current_participant, @current_participant, :url => { :action => "change_participant_status", :id => @meeting } do |form| %> +
+ Планы +
+ <%= form.radio_button :status, Participant::PLAN::YES %> Пойду
+ <%= form.radio_button :status, Participant::PLAN::MAYBE %> Возможно пойду
+ <%= form.radio_button :status, Participant::PLAN::NO %> Не пойду
+ <%= submit_tag "Ответ на приглашение" %> +
+
+ <% end %> +
+<% end %> + <% if @meeting.has_participant? current_user %> + + <%= link_to 'Посмотреть/Добавить фотографии', :action => "add_photos", :id => @meeting %> + <% elsif !logged_in?%> + <% else %> + <%= link_to 'Участвовать', :action => "join", :id => @meeting %> + <% end %> + <%if @meeting.user_id == current_user.id %> + | <%= link_to 'Править', edit_meeting_path(:id => @meeting) %> +<% end %> +
+<%= render :partial => 'participants' %> +
+

<%='Комментарии'._%>

+<% if @comments.size > 0 %> +<% @comment_obj = @meeting %> +<%= render :partial => 'users/comments' %> +<% else %> +

Нет

+<% end %> + +<% if is_allowed_to_post(@meeting.user) %> + <%='Мой коментарий к этому сообщению'._%>: + <% form_tag :action => 'add_comment', :id => @meeting.id do %> + <%= hidden_field_tag 'meeting_id', @meeting.id %> + <%= text_area 'comment', 'message', :rows => '4', :style=>"width:100%" %> + + <%= 'Показать Смайлы'._ %> + + <%= submit_tag '» ' + 'Сказать'._ %> + <% end %> +<% end %>
+ <%= render :partial => 'shared/smiles', :locals => { :input_id => "comment_message" } %> + + diff --git a/app/views/meetings/update.html.erb b/app/views/meetings/update.html.erb new file mode 100644 index 0000000..601d774 --- /dev/null +++ b/app/views/meetings/update.html.erb @@ -0,0 +1,2 @@ +

Meetings#update

+

Find me in app/views/meetings/update.html.erb

diff --git a/app/views/spam_messages/revise_spam_messages.html.erb b/app/views/spam_messages/revise_spam_messages.html.erb index f714fbd..27d0ba2 100644 --- a/app/views/spam_messages/revise_spam_messages.html.erb +++ b/app/views/spam_messages/revise_spam_messages.html.erb @@ -27,7 +27,7 @@ <% elsif spam_message.spam_status == SpamMessage::SPAM_STATUS::SPAM %> <%= link_to 'не спам', { :action => "revise_cancel_status", :id => spam_message.id}, :confirm => 'Точно?' %> <% elsif spam_message.spam_status == SpamMessage::SPAM_STATUS::REVISED_SPAM || spam_message.spam_status == SpamMessage::SPAM_STATUS::REVISED_NOT_SPAM %> - Nothing to do + Nothing to do <% end -%> | <%= link_to 'показать', :action => "show_revise", :id => spam_message.id %>