Permalink
Browse files

Merge pull request #66 from geeksforsocialchange/master

Merge master into production
  • Loading branch information...
GabAlexandria committed Sep 12, 2018
2 parents e504320 + b03399f commit 8be18a7324f9550c581375c2a8626fe6a127d218
Showing with 460 additions and 278 deletions.
  1. +2 −1 Gemfile
  2. +7 −3 Gemfile.lock
  3. +12 −5 app/components/event/_event.html.erb
  4. +25 −3 app/components/event/event.sass
  5. +43 −26 app/components/event/event.yml
  6. +35 −18 app/components/event/event_component.rb
  7. +3 −14 app/components/event_list/_event_list.html.erb
  8. +2 −6 app/controllers/admin/calendars_controller.rb
  9. +24 −1 app/controllers/admin/users_controller.rb
  10. +9 −0 app/controllers/users/invitations_controller.rb
  11. +0 −55 app/controllers/users_controller.rb
  12. +53 −11 app/models/address.rb
  13. +4 −0 app/models/event.rb
  14. +12 −9 app/models/events/base.rb
  15. +1 −1 app/models/place.rb
  16. +8 −0 app/models/turf.rb
  17. +11 −1 app/models/user.rb
  18. +30 −2 app/policies/calendar_policy.rb
  19. +1 −1 app/policies/user_policy.rb
  20. +2 −2 app/views/admin/calendars/_form.html.erb
  21. 0 app/views/{ → admin}/users/_contact.html.erb
  22. +12 −0 app/views/admin/users/_form.html.erb
  23. +2 −10 app/views/admin/users/edit.html.erb
  24. +8 −0 app/views/admin/users/new.html.erb
  25. +2 −2 app/views/admin/users/profile.html.erb
  26. +1 −8 app/views/events/activities.html.erb
  27. +3 −12 app/views/events/show.html.erb
  28. +4 −1 app/views/layouts/admin/_admin_navigation.html.erb
  29. +7 −1 app/views/places/index.html.erb
  30. +0 −17 app/views/users/_form.html.erb
  31. +0 −4 app/views/users/_user.json.jbuilder
  32. +0 −6 app/views/users/edit.html.erb
  33. +0 −18 app/views/users/index.html.erb
  34. +0 −3 app/views/users/index.json.jbuilder
  35. +0 −5 app/views/users/new.html.erb
  36. +0 −4 app/views/users/show.html.erb
  37. +0 −3 app/views/users/show.json.jbuilder
  38. +2 −0 config/environments/development.rb
  39. +48 −0 config/initializers/devise.rb
  40. +4 −9 config/initializers/geocoder.rb
  41. +31 −0 config/locales/devise_invitable.en.yml
  42. +1 −4 config/routes.rb
  43. +17 −0 db/migrate/20180827120116_add_devise_invitable.rb
  44. +5 −0 db/migrate/20180905123823_add_admin_ward_to_addresses.rb
  45. +12 −4 db/schema.rb
  46. BIN erd.pdf
  47. +17 −8 test/controllers/admin/calendars_controller_test.rb
View
@@ -36,9 +36,10 @@ gem 'bootstrap-sass', '~> 3.3.7'
# Misc
gem 'active_link_to'
gem 'devise'
gem 'devise_invitable'
gem 'enumerize'
gem 'friendly_id', '~> 5.1.0'
gem 'geocoder'
gem 'geocoder', '~> 1.5.0' # postcodes.io was added in 1.4.9, the final version before 1.5.0
gem 'jbuilder', '~> 2.5'
gem 'koala'
gem 'leaflet-rails'
View
@@ -125,6 +125,9 @@ GEM
railties (>= 4.1.0, < 6.0)
responders
warden (~> 1.2.3)
devise_invitable (1.7.4)
actionmailer (>= 4.1.0)
devise (>= 4.0.0)
docile (1.3.0)
domain_name (0.5.20180417)
unf (>= 0.0.5, < 1.0.0)
@@ -154,7 +157,7 @@ GEM
formatador (0.2.5)
friendly_id (5.1.0)
activerecord (>= 4.0.0)
geocoder (1.4.7)
geocoder (1.5.0)
globalid (0.4.1)
activesupport (>= 4.2.0)
groupdate (4.0.0)
@@ -484,12 +487,13 @@ DEPENDENCIES
coffee-rails (~> 4.2)
delayed_job_active_record
devise
devise_invitable
dotenv-rails
enumerize
factory_bot_rails
faker
friendly_id (~> 5.1.0)
geocoder
geocoder (~> 1.5.0)
groupdate
guard
guard-livereload (~> 2.5)
@@ -548,4 +552,4 @@ RUBY VERSION
ruby 2.4.3p205
BUNDLED WITH
1.16.1
1.16.2
@@ -4,7 +4,14 @@
<%= render_component "hero", title: summary %>
<div class="c">
<% else %>
<h3 itemprop="name"><%= link_to summary, event_path(properties[:id]) %></h3>
<div class="event__header">
<h3 itemprop="name"><%= link_to summary, event_path(id) %></h3>
<% if admin_ward %>
<div class="event__turf">
<span><%= admin_ward %></span>
</div>
<% end %>
</div>
<% end %>
<div class="event__details">
<div class="event__detail event__time">
@@ -21,12 +28,12 @@
<span class="icon icon--date">📅</span>
<%= date %>
</div>
<% if properties[:place] || properties[:location] %>
<% if place || location %>
<div class="event__detail event__location">
<span class="icon icon--place">🏠</span>
<% if properties[:place] %>
<%= link_to properties[:place], place_path(properties[:place]) %>
<% elsif properties[:location] %>
<% if place %>
<%= link_to place, place_path(place) %>
<% elsif location %>
<%= location %>
<% end %>
</div>
@@ -8,14 +8,36 @@
margin-bottom: 2rem
h3
margin-bottom: 0.5em
display: inline-block
a
border-bottom-width: 0
text-decoration: none
&__header
display: grid
grid-template-columns: 1fr
+for-tablet-portrait-up
grid-template-columns: 1fr auto
align-items: center
&__turf
// padding-top: 0.5rem
span
+for-phone-only
display: none
margin-top: 0.8rem
padding: 0rem 0.7rem
display: inline-block
text-transform: uppercase
font-weight: $extra-bold
font-size: 0.77777778rem
border-radius: 1rem
letter-spacing: 0.086667rem
background-color: $green
color: $cream
&__details
+flexbox
+flex-wrap(wrap)
+align-items(center)
+justify-content(flex-start)
+align-items(center)
+justify-content(flex-start)
border-width: 3px 0
border-color: $linen
border-style: solid
@@ -26,7 +48,7 @@
width: 1.75rem
height: 1.75rem
margin-right: 0.25rem
&--full
&--full
.event__details
border-top-width: 0
border-bottom-width: 10px
@@ -1,30 +1,47 @@
:meta: 'One event with varying information'
:stubs:
:meta: 'One event with varying information'
:stubs:
-
:id: 1
:summary: 'Event with just a date, time and summary'
:dtstart: 2017-10-02 12:30:00
:dtend: 2017-10-02 14:00:00
:event: !ruby/object:OpenStruct
table:
:id: 1
:summary: 'Event with just a date, time and summary'
:dtstart: 2017-10-02 12:30:00
:dtend: 2017-10-02 14:00:00
-
:id: 2
:summary: 'Event with a Location'
:dtstart: 2017-10-02 10:30:00
:dtend: 2017-10-02 14:00:00
:location: 'Name of room or un-geolocated address'
:event: !ruby/object:OpenStruct
table:
:id: 2
:summary: 'Event with a location and neighbourhood turf'
:dtstart: 2017-10-02 10:30:00
:dtend: 2017-10-02 14:00:00
:location: "Name of room or un-geolocated address"
:neighbourhood_turf: !ruby/object:OpenStruct
table:
:name: Turfy
-
:id: 3
:summary: 'Event with a Place chooses place over address'
:dtstart: 2017-10-02 12:00:00
:dtend: 2017-10-02 14:00:00
:location: 'Will be ignored'
:place: Place that PlaceCal knows about
:event: !ruby/object:OpenStruct
table:
:id: 3
:summary: 'Event with a Place chooses place over address'
:dtstart: 2017-10-02 12:00:00
:dtend: 2017-10-02 14:00:00
:location: "Will be ignored"
:place: Place that PlaceCal knows about
:neighbourhood_turf: !ruby/object:OpenStruct
table:
:name: Turfy
-
:id: 4
:summary: 'Event that repeats weekly'
:dtstart: 2017-10-02 12:00:00
:dtend: 2017-10-02 14:00:00
:place: Place that PlaceCal knows about
:rrule:
-
table:
frequency: WEEKLY
:event: !ruby/object:OpenStruct
table:
:id: 4
:summary: 'Event that repeats weekly'
:dtstart: 2017-10-02 12:00:00
:dtend: 2017-10-02 14:00:00
:place: Place that PlaceCal knows about
:rrule:
-
table:
frequency: WEEKLY
:neighbourhood_turf: !ruby/object:OpenStruct
table:
:name: Turfy
@@ -2,54 +2,69 @@
# app/components/event/event_component.rb
class EventComponent < MountainView::Presenter
properties :summary, :description, :dtstart, :dtend,
:location, :context, :place
properties :context, :event
include ActionView::Helpers::TextHelper
def id
event.id
end
def place
event.place
end
def location
event.location
end
def time
if dtend
fmt_time(dtstart) + '' + fmt_time(dtend)
if event.dtend
fmt_time(event.dtstart) + '' + fmt_time(event.dtend)
else
fmt_time(dtstart)
fmt_time(event.dtstart)
end
end
def duration
return false unless dtend
mins = ((dtend - dtstart) / 60).to_i
return false unless event.dtend
mins = ((event.dtend - event.dtstart) / 60).to_i
hours = mins / 60 # Ruby presumes ints not floats, and rounds down
mins_str = (mins % 60).positive? ? "#{mins % 60} mins" : ''
hours_str = hours.positive? ? pluralize(hours, 'hour') : ''
[hours_str, mins_str].reject(&:empty?).join(' ')
end
def date
dtstart.strftime('%e %b')
event.dtstart.strftime('%e %b')
end
def summary
properties[:summary]
event.summary
end
def description
properties[:description]
event.description
end
def page?
properties[:context] == :page
context == :page
end
def partner
properties[:partner].first
event.partner.first
end
def location
properties[:location].split(',').first&.delete('\\')
event.location&.split(',')&.first&.delete('\\')
end
def repeats
properties[:rrule].present? ? properties[:rrule][0]['table']['frequency'].titleize : false
event.rrule.present? ? event.rrule[0]['table']['frequency'].titleize : false
end
def admin_ward
event.admin_ward
end
private
@@ -62,11 +77,13 @@ def fmt_time(time)
end
end
def dtstart
properties[:dtstart]
# Prevent method-access in erb file for named properties.
def event
properties[:event]
end
def dtend
properties[:dtend]
def context
properties[:context]
end
end
@@ -1,5 +1,5 @@
<% if show_paginator %>
<%= render_component "paginator",
<%= render_component "paginator",
pointer: pointer,
period: period,
sort: sort,
@@ -14,22 +14,11 @@
<ol class="events reset">
<% events.each do |event| %>
<li>
<%= render_component "event",
context: @period,
id: event.id,
path: event_path(event),
place: event.place,
partner: event.partner,
summary: event.summary,
dtstart: event.dtstart,
dtend: event.dtend,
rrule: event.rrule,
location: event.location
%>
<%= render_component "event", context: @period, event: event %>
</li>
<% end %>
</ol>
<% end %>
<% else %>
<p>No events with this selection.</p>
<% end %>
<% end %>
@@ -16,8 +16,6 @@ def new
end
def edit
authorize @calendar
@versions = @calendar.recent_activity
end
@@ -37,7 +35,6 @@ def create
end
def update
authorize @calendar
if @calendar.update_attributes(calendar_params)
redirect_to admin_calendars_path
else
@@ -54,8 +51,6 @@ def destroy
end
def import
authorize @calendar, :import?
begin
date = DateTime.parse(params[:starting_from])
@@ -80,7 +75,8 @@ def select_page
private
def set_calendar
@calendar = Calendar.find(params[:id])
@calendar = policy_scope(Calendar).find(params[:id])
authorize @calendar
end
def calendar_params
Oops, something went wrong.

0 comments on commit 8be18a7

Please sign in to comment.