An open source, stand-alone, customisable public spending data web app.
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

vor 14 Jahren
vor 14 Jahren
vor 14 Jahren
vor 14 Jahren
vor 14 Jahren
vor 14 Jahren
vor 14 Jahren
vor 14 Jahren
vor 14 Jahren
vor 14 Jahren
vor 14 Jahren
vor 14 Jahren
vor 14 Jahren
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. require 'rubygems'
  2. require 'dm-core'
  3. require 'dm-validations'
  4. require 'dm-timestamps'
  5. require 'dm-aggregates'
  6. require 'dm-serializer'
  7. require 'dm-migrations'
  8. class Payment
  9. include DataMapper::Resource
  10. property :id, Serial
  11. property :created_at, DateTime
  12. property :updated_at, DateTime
  13. property :service_id, Integer, :required => true
  14. property :supplier_id, Integer, :required => true
  15. property :amount, BigDecimal, :precision => 10, :scale => 2, :required => true # ex VAT
  16. property :d, Date, :required => true # transaction date
  17. belongs_to :service
  18. belongs_to :supplier
  19. has 1, :directorate, { :through => :service }
  20. def url
  21. SETTING.site_url + "payments/" + @id.to_s
  22. end
  23. end
  24. class Directorate
  25. include DataMapper::Resource
  26. property :id, Serial
  27. property :created_at, DateTime
  28. property :updated_at, DateTime
  29. property :name, String, :length => 255, :required => true
  30. property :slug, String, :length => 255
  31. has n, :services, :order => ['name']
  32. has n, :suppliers, { :through => :services, :order => ['name'] }
  33. before :save, :slugify
  34. def slugify
  35. @slug = @name.gsub(/[^\w\s-]/, '').gsub(/\s+/, '-').downcase
  36. end
  37. end
  38. class Service
  39. include DataMapper::Resource
  40. property :id, Serial
  41. property :created_at, DateTime
  42. property :updated_at, DateTime
  43. property :directorate_id, Integer, :required => true
  44. property :name, String, :length => 255, :required => true
  45. property :slug, String, :length => 255
  46. has n, :payments, :order => ['d']
  47. has n, :suppliers, { :through => :payments, :order => ['name'] }
  48. belongs_to :directorate
  49. before :save, :slugify
  50. def slugify
  51. @slug = @name.gsub(/[^\w\s-]/, '').gsub(/\s+/, '-').downcase
  52. end
  53. end
  54. class Supplier
  55. include DataMapper::Resource
  56. property :id, Serial
  57. property :created_at, DateTime
  58. property :updated_at, DateTime
  59. property :name, String, :length => 255, :required => true
  60. property :slug, String, :length => 255
  61. has n, :payments, :order => ['d']
  62. has n, :services, { :through => :payments, :order => ['name'] }
  63. has n, :directorates, { :through => :payments }
  64. before :save, :slugify
  65. def slugify
  66. @slug = @name.gsub(/[^\w\s-]/, '').gsub(/\s+/, '-').downcase
  67. end
  68. end
  69. class Council
  70. include DataMapper::Resource
  71. property :id, Serial
  72. property :created_at, DateTime
  73. property :updated_at, DateTime
  74. property :name, String, :length => 255, :required => true
  75. property :slug, String, :length => 255
  76. property :url, String, :length => 255
  77. property :data_url, String, :length => 512
  78. property :open_licence, Boolean, :default => false
  79. property :machine_readable, Boolean, :default => false
  80. property :start_d, Date
  81. property :end_d, Date
  82. before :save, :slugify
  83. def slugify
  84. @slug = @name.gsub(/[^\w\s-]/, '').gsub(/\s+/, '-').downcase
  85. end
  86. end
  87. # This is a singleton. We only use the first row in the settings table.
  88. class Setting
  89. include DataMapper::Resource
  90. property :id, Serial
  91. property :site_name, String, :length => 255, :required => true
  92. property :site_tagline, String, :length => 255
  93. property :site_url, String, :length => 255
  94. property :org_name, String, :length => 255
  95. property :org_url, String, :length => 255
  96. property :data_url, String, :length => 255
  97. end
  98. DataMapper.setup(:default, ENV['DATABASE_URL'] || "sqlite3://#{Dir.pwd}/db.sqlite3")
  99. DataMapper.auto_upgrade!