Browse files

merged master, fixed account settings, fixed google calendar sync

  • Loading branch information...
2 parents ee527e4 + 3b1a040 commit f2c2e5373eedf68968ddd19d4617f3f1014600fb @pedelman pedelman committed Dec 8, 2012
View
2 lib/model/base.rb
@@ -108,7 +108,7 @@ class Category
# def name=(n)
# @name = n
- # event.category_name = n
+ # event.category.name = n
# end
end
View
21 lib/model/data_generator.rb
@@ -344,16 +344,23 @@ def rand_events(max_events=25)
users.each do |user|
print "."
(1..(1 + rand(max_events))).each do |i|
- categories = ["work",
- "entertainment",
- "personal",
- "school",
- "outdoor",
- "etc"]
+ categories = ["outdoor",
+ "personal",
+ "music",
+ "tv",
+ "movies",
+ "entertainment",
+ "art",
+ "community",
+ "etc",
+ "school",
+ "sports",
+ "political",
+ "charity"]
rand_category = categories[rand(categories.size)]
title_seed = rand(titles.count)
description_seed = rand(descriptions.count)
- new_event = Event.create(title: titles[title_seed], body: descriptions[description_seed], user: user, img_url: "/images/banksy/thumb/#{(1 + rand(19))}.jpg")
+ new_event = Event.create(title: titles[title_seed], body: descriptions[description_seed], user: user, img_url: "/images/banksy/thumb/#{(1 + rand(19))}.jpg", start_date: DateTime.now, end_date: DateTime.now.next_day)
category = Category.create(event: new_event)
new_event.category.name = rand_category
new_event.save
View
21 lib/model/event.rb
@@ -8,9 +8,8 @@ class Event
property :location, String, default: ""
property :permission, String, default: "public"
property :event_date, DateTime, default: DateTime.now
- property :category_name, String, default: ""
- property :start_date, DateTime
- property :end_date, DateTime
+ property :start_date, DateTime, default: DateTime.now
+ property :end_date, DateTime, default: DateTime.now
property :updated_at, DateTime
property :created_at, DateTime, default: DateTime.now # A DateTime, for any date you might like.
property :body, Text # A text block, for longer string data.
@@ -56,7 +55,7 @@ def toggle_google_calendar_event(user_uuid)
else
result = client.execute(:api_method => service.events.insert,
:parameters => {'calendarId' => SessionController.user(user_uuid).email},
- :body => JSON.dump(generate_google_event_json("Test Location", self.body, self.title)),
+ :body => JSON.dump(generate_google_event_json),
:headers => {'Content-Type' => 'application/json'})
success = update google_calendar_id: result.data.id
return_msg = "synched"
@@ -65,16 +64,14 @@ def toggle_google_calendar_event(user_uuid)
return success ? return_msg : "failed"
end
- def generate_google_event_json(location, description, title)
- start_date = "2012-11-5"
- end_date = "2012-11-8"
+ def generate_google_event_json
{
- "start" => { "date" => start_date },
- "end" => { "date" => end_date },
- "location" => location,
+ "start" => { "date" => self.start_date.strftime("%Y-%m-%d") },
+ "end" => { "date" => self.end_date.strftime("%Y-%m-%d") },
+ "location" => self.location,
"transparency" => "transparent",
- "description" => body,
- "summary" => title,
+ "description" => self.body,
+ "summary" => self.title,
"status" => "confirmed"
}
end
View
2 lib/model/user.rb
@@ -23,6 +23,8 @@ class Link #from http://datamapper.org/docs/associations.html
property :location, String
property :email, String
property :password, String
+ property :display_name, String
+ property :location, String
property :salt, String
property :session_id, String
property :hashed_password, String
View
9 lib/routes/api/api.rb
@@ -77,7 +77,7 @@
response_str = ""
user.events.each do |event|
element = render_pane({title: event.title,
- classes: event.category_name,
+ classes: event.category.name,
id: event.id,
category: event.category.name,
tumbler: event.tumbler,
@@ -101,7 +101,7 @@
events = user.stream_events(100)
events.each do |event|
element = render_pane({title: event.title,
- classes: event.category_name,
+ classes: event.category.name,
id: event.id,
category: event.category.name,
tumbler: event.tumbler,
@@ -134,11 +134,12 @@
events = events[(range_vals[0].to_i..range_vals[1].to_i)]
events.each do |event|
element = render_pane({title: event.title,
- classes: event.category_name,
+ classes: event.category.name,
id: event.id,
category: event.category.name,
tumbler: event.tumbler,
- event_time: event.event_date,
+ start_date: event.start_date,
+ end_date: event.end_date,
img_url: event.img_url,
user_name: event.user.user_name,
event: event})
View
2 lib/routes/search/search.rb
@@ -50,7 +50,7 @@ def self.search(opts)
search_term << params[:args].gsub('%20', '%')
search_term << "%"
e1 = Event.all(:title.like => search_term, permission: "public")
- e2 = Event.all(:category_name.like => search_term, permission: "public")
+ e2 = Event.all(:category.name.like => search_term, permission: "public")
@events = e1.zip(e2).flatten.compact
categories = Set[]
@events.each do |e|
View
28 lib/routes/user/user.rb
@@ -37,10 +37,26 @@
## Events ####################################################
##############################################################
+def categories
+ ["outdoor",
+ "personal",
+ "music",
+ "tv",
+ "movies",
+ "entertainment",
+ "art",
+ "community",
+ "etc",
+ "school",
+ "sports",
+ "political",
+ "charity"]
+end
+
get '/user/:user_name/stream' do
@user = current_user
unless @user.nil?
- @categories = @user.account_setting.categories.split('&')
+ @categories = categories
@sidebar = user_sidebar(@user)
@breadcrumbs = bread_crumbs_partial request.path_info.split('/')
haml :'user/dashboard', locals: {categories: @categories}, layout: :'layout/user'
@@ -52,7 +68,7 @@
get '/user/:user_name/events' do
@user = current_user
unless @user.nil?
- @categories = @user.account_setting.categories.split('&')
+ @categories = categories
@sidebar = user_sidebar(@user)
@breadcrumbs = bread_crumbs_partial request.path_info.split('/')
haml :'user/events', locals: {categories: @categories}, layout: :'layout/user'
@@ -254,5 +270,11 @@
end
##############################################################
-
+post '/user/:username/account' do
+ @user = current_user
+ @user.display_name = params[:display_name]
+ @user.location = params[:location]
+ @user.save!
+ redirect '/'
+end
View
4 lib/views/event/event.haml
@@ -57,9 +57,9 @@
#event_map{:style => "width:400px;height:300px;"}
.row#follow-tray
-if current_user.following?(event.user) || current_user == event.user
- %p.btn.btn-primary.following-btn= "Following #{event.user.user_name}"
+ %p.btn.btn-primary.following-btn= "Following #{event.user.display_name ? event.user.display_name : event.user.user_name}"
-else
- %a.btn.btn-warning.follow-btn{id: "followed-user-#{event.user.user_name}-#{event.user.id}"}= "Follow #{event.user.user_name}"
+ %a.btn.btn-warning.follow-btn{id: "followed-user-#{event.user.user_name}-#{event.user.id}"}= "Follow #{event.user.display_name ? event.user.display_name : event.user.user_name}"
.row
%h4= "comments"
%hr
View
4 lib/views/looking_glass/tile.haml
@@ -22,8 +22,8 @@
.row
%h1.window-pane= map[:title]
.row
- -#%h3.name= map[:category]
- %p.event-date= map[:start_date]#.strftime("%m/%d/%Y")
+ %h3.name= map[:category]
+ %p.event-date= map[:event].start_date.strftime("%m/%d/%Y")
-#%p.user_name= map[:user_name]
-#.row
-#%p.comment-count= "#{map[:tumbler].comments.count}"
View
12 lib/views/user/account.haml
@@ -8,15 +8,15 @@
.content.span9
-#%h2.center= user.user_name.to_s
%img.center_block.mid_mb{:src => gravatar_for(user,200)}
- %form.form-horizontal{ :action => "/user/#{user.email}/account", :method => "post"}
+ %form.form-horizontal{:action => "", :method => "post"}
.control-group
- %label.control-label{:for => "inputUrl"}
+ %label.control-label{:for => "inputDisplayName"}
Display Name
.controls
- %input#inputDisplayName{:value => "#{user.display_name}", :placeholder => "Display Name", :type => "text", :name => "display_name"}
+ %input#inputDisplayName{:name => "display_name", :placeholder => "Display Name", :type => "text", :value => "#{user.display_name}"}
.control-group
- %label.control-label{:for => "inputUrl"}
+ %label.control-label{:for => "location"}
Location
.controls
- %input#inputUrl{:value => "#{user.location}", :placeholder => "Location", :type => "text", :name => "location"}
- %input.center_block{:type => "submit", :class => "btn", :value => "Update"}/
+ %input#location{:value => "#{user.location}",:name => "location", :placeholder => "Location", :type => "text"}
+ %input.center_block{:type => "submit", :class => "btn", :name => "Update"}/
View
3 lib/views/user/dashboard.haml
@@ -42,7 +42,8 @@
$container.isotope('insert', html);
// add the click handlers for the new elements
$('.google-event-btn').click(function(e) {
- var event_id = $(this).parent().parent().parent().parent().attr('data-symbol');
+ var event_id = $(this).parent().parent().parent().parent().parent().parent().attr('data-symbol');
+ console.log(event_id);
e.preventDefault();
$.ajax({
type: "POST",

0 comments on commit f2c2e53

Please sign in to comment.