Fixed time zone naming. Also set default calendars on init setup based on browsers location. Ignore private ip ranges of browsers.

This commit is contained in:
Martin Edenhofer 2015-09-29 10:23:13 +02:00
parent 4944bfa809
commit 513e695894
5 changed files with 9 additions and 6 deletions

View file

@ -5,7 +5,7 @@ class App.Calendar extends App.Model
@configure_attributes = [
{ name: 'name', display: 'Name', tag: 'input', type: 'text', limit: 100, null: false },
{ name: 'timezone', display: 'Timezone', tag: 'timezone', null: false }
{ name: 'timezone', display: 'Time zone', tag: 'timezone', null: false }
{ name: 'business_hours', display: 'Business Hours', tag: 'business_hours', null: true }
{ name: 'ical_url', display: 'Holidays iCalendar Feed', tag: 'ical_feed', placeholder: 'http://example.com/public_holidays.ical', null: true }
{ name: 'public_holidays',display: 'Holidays', tag: 'holiday_selector', null: true }

View file

@ -33,7 +33,7 @@
</div>
<% if calendar.last_log: %><div class="action-row"><div class="alert alert--danger"><%= calendar.last_log %></div></div><% end %>
<div class="action-row">
<div class="label"><%- @T('Timezone') %></div> <%= calendar.timezone %>
<div class="label"><%- @T('Time zone') %></div> <%= calendar.timezone %>
</div>
<div class="action-block action-block--flex">
<div class="label"><%- @T('Business Hours') %></div>

View file

@ -43,6 +43,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
end
# return result
Calendar.init_setup(request.remote_ip)
render json: {
setup_done: setup_done,
import_mode: Setting.get('import_mode'),
@ -212,10 +213,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
def setup_done_response
return false if !setup_done
# get all groups
groups = Group.where( active: true )
# get email addresses
addresses = EmailAddress.where( active: true )
render json: {

View file

@ -22,6 +22,11 @@ returns calendar object
def self.init_setup(ip = nil)
# ignore client ip if not public ip
if ip && ip =~ /^(::1|127\.|10\.|172\.1[6-9]\.|172\.2[0-9]\.|172\.3[0-1]\.|192\.168\.)/
ip = nil
end
# call for calendar suggestion
calendar_details = Service::GeoCalendar.location(ip)
return if !calendar_details

View file

@ -34,7 +34,7 @@ class Service::GeoCalendar::Zammad
data = response.data
Cache.write( cache_key, data, { expires_in: 1.day } )
Cache.write( cache_key, data, { expires_in: 30.minutes } )
rescue => e
Rails.logger.error "#{host}#{url}: #{e.inspect}"
Cache.write( cache_key, data, { expires_in: 1.minutes } )