Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fix and enhancement #323

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
25 changes: 9 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
GS5
===
Gemeinschaft 5 by [AMOOMA GmbH](http://amooma.de) in Germany. It is a FreeSWITCH and Ruby on Rails based PBX. This Github repository is our development environment.
Gemeinschaft 5 by AMOOMA GmbH in Germany. It is a FreeSWITCH and Ruby on Rails based PBX.

MIT License
===========
Copyright (c) 2013 AMOOMA GmbH
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Documentation
=============
Expand All @@ -14,20 +21,6 @@ Feature requests
================
Please open a new issue and mark it as a feature request.

Roadmap
=======
We don't have a public roadmap. But we do track the future work with issues. So have a look at [https://github.com/amooma/GS5/issues](https://github.com/amooma/GS5/issues) for future features.

License
=======
We use this public repository to develop. Do not use this code on a production system! Do not give away this code to your clients! This code is strictly for development purposes and GS5 is not a GPL project.

DO NOT USE CODE FROM THE CONTENT OF THIS REPOSITORY FOR A PRODUCTION SYSTEM!

You can download a free and stable version of GS5 for your production system at [http://amooma.de/gemeinschaft/gs5](http://amooma.de/gemeinschaft/gs5).

Development How-to
==================
There is a master and a develop branch in this repository. If you are familiar with [http://nvie.com/posts/a-successful-git-branching-model/](http://nvie.com/posts/a-successful-git-branching-model/) you are good to go. Please send a pull request and an e-mail to [email protected] with some info about your code. Regular developer get access to the repository, a closed developer mailinglist and hardware in case they need it.

We only accept code which was written 100% by you and were you grant us the rights for the code.
There is a master and a develop branch in this repository. If you are familiar with [http://nvie.com/posts/a-successful-git-branching-model/](http://nvie.com/posts/a-successful-git-branching-model/) you are good to go. Pull request is your friend.
2 changes: 1 addition & 1 deletion app/controllers/config_gigaset_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ def phone_book
phone_book_ids << phone_book.id
end

ln = params[:ln].to_s.encode!('UTF-8', 'UTF-8', :invalid => :replace).gsub(/[^0-9a-zA-Z-_]/,'_') + '%'
ln = params[:ln].to_s.encode!('UTF-8', 'UTF-8', :invalid => :replace).gsub(/[^0-9a-zA-Z\-_]/,'_') + '%'
hm = params[:hm].to_s + '%'

@phone_book_entries = PhoneBookEntry.where(:phone_book_id => phone_book_ids).where('last_name LIKE ?', ln).order(:last_name).order(:first_name).limit(MAX_DIRECTORY_ENTRIES)
Expand Down
4 changes: 2 additions & 2 deletions config/locales/views/gemeinschaft_setups/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ en:
hint: ''
default_area_code:
label: 'Default area code'
hint: ''
hint: 'without the leading zero; e.g. 30 for Berlin'
trunk_access_code:
label: 'Trunk access code'
hint: ''
Expand All @@ -43,4 +43,4 @@ en:
report_attacks:
label: 'Report attacks'
hint: 'Report attacks to the cloud.'
submit: 'Create this PBX'
submit: 'Create this PBX'
10 changes: 10 additions & 0 deletions lib/tasks/backup.rake
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,14 @@ namespace :backup do
end
end

desc "Cleanup backups."
task :cleanup, [:daystokeep] => :environment do |t,a|
# this task will purge all backups started before :daystokeep (default 90) days from disk and database to save disk space
# usage: rake backup:cleanup[14]
a.with_defaults(:daystokeep => 90)
cleanuptime = Time.now - a.daystokeep.to_i.day
puts "Deleting backups to #{cleanuptime.to_s} ..."
BackupJob.where("started_at < ?",cleanuptime).find_each { |entry| entry.destroy }
puts "Done."
end
end
95 changes: 95 additions & 0 deletions lib/tasks/csv_phonebook.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
namespace :csvphonebook do
require 'csv'

#
# CSV format (headers are inspired by LDAP attributes).
# Columns givenName,sn,company are mandatory, other columns are optional.
#
# givenName,sn,company,telephoneNumber,mobile,department,streetAddress,postalCode,l,title,co
# Max,Mustermann,Musterfirma,+123456789,+91123456789,Abteilung XY,Musterstraße 1 a,12345,Musterstadt,Musterchief,Germany
#
#
# usage:
# rake csvphonebook:add[/path/to/file.csv,"name of phone book"]
# rake csvphonebook:delete[/path/to/file.csv,"name of phone book"]
#

desc "Delete phonebook entries from a CSV file."
task :delete, [:csvfile, :phonebookname] => :environment do |t,a|

csv_data = CSV.read(a.csvfile, encoding: 'UTF-8')
phonebookid = PhoneBook.find(:first, :conditions => { :name => a.phonebookname}).id
headers = csv_data.shift.map {|i| i.to_s }
string_data = csv_data.map {|row| row.map {|cell| cell.to_s } }
entries = string_data.map {|row| Hash[*headers.zip(row).flatten] }

entries.each do |entry|
if !(entry['givenName'].blank? || entry['sn'].blank? || entry['company'].blank?)
pbe = PhoneBookEntry.find(:first,:conditions => {
:phone_book_id => phonebookid,
:first_name => entry['givenName'],
:last_name => entry['sn'],
:organization => entry['company']
})
if !pbe.nil?
pbe.delete
end
end
end
end

desc "Add new phonebook entries from CSV file."
task :add, [:csvfile, :phonebookname] => :environment do |t,a|

csv_data = CSV.read(a.csvfile, encoding: 'UTF-8')
phonebookid = PhoneBook.find(:first, :conditions => { :name => a.phonebookname}).id
headers = csv_data.shift.map {|i| i.to_s }
string_data = csv_data.map {|row| row.map {|cell| cell.to_s } }
entries = string_data.map {|row| Hash[*headers.zip(row).flatten] }

entries.each do |entry|
if !(entry['givenName'].blank? || entry['sn'].blank? || entry['company'].blank?)
pbe = PhoneBookEntry.new
pbe.first_name = entry['givenName']
pbe.last_name = entry['sn']
pbe.organization = entry['company']
pbe.is_male = 1
pbe.department = entry['department']
pbe.job_title = entry['title']
pbe.phone_book_id = phonebookid
pbe.save

if !(entry['telephoneNumber'].blank?)
number = PhoneNumber.new
number.name = 'Office'
number.number = entry['telephoneNumber']
number.phone_numberable_type = 'PhoneBookEntry'
number.phone_numberable_id = pbe.id
number.save
end
if !(entry['mobile'].blank?)
number = PhoneNumber.new
number.name = 'Mobile'
number.number = entry['mobile']
number.phone_numberable_type = 'PhoneBookEntry'
number.phone_numberable_id = pbe.id
number.save
end
if !(entry['streetAddress'].blank? && entry['postalCode'].blank? && entry['l'].blank? && entry['co'].blank?)
addr = Address.new
addr.street = entry['streetAddress']
addr.zip_code = entry['postalCode']
addr.city = entry['l']
if !entry['co'].blank?
country = Country.find(:first, :conditions => { :name => entry['co']})
if !country.nil?
addr.country_id = country.id
end
end
addr.phone_book_entry_id = pbe.id
addr.save
end
end
end
end
end