Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allow classification into subsections.

  • Loading branch information...
commit 94cf2538d5c071a3baec4a09cf452ba5b4d4ab7c 1 parent f4266b2
@heathd heathd authored
View
27 app/models/artefact.rb
@@ -1,18 +1,21 @@
class Artefact < ActiveRecord::Base
MAXIMUM_RELATED_ITEMS = 8
- SECTIONS = [
- 'Crime and justice',
- 'Education',
- 'Work',
- 'Family',
- 'Money and Tax',
- 'Driving',
- 'Housing',
- 'Travel',
- 'Life in the UK',
- 'Neighbourhoods'
- ].freeze
+ def self.sections
+ @@sections ||= load_sections
+ end
+
+ def self.load_sections
+ section = nil
+ File.open(Rails.root.join('app', 'models', 'sections.txt'), 'r').map do |line|
+ if line =~ /^ /
+ raise "Bad section.txt, must start with a section (no spaces at start of first line)" if section.nil?
+ "#{section}:#{line.strip}"
+ else
+ section = line.strip
+ end
+ end
+ end
FORMATS = [
"answer",
View
89 app/models/sections.txt
@@ -0,0 +1,89 @@
+Crime and justice
+ Reporting crime
+ Terrorism and extremism
+ The police
+ Courts
+ Sentencing
+ Prisons and probation
+ Complaints
+ Young people and crime
+ Your neighbourhood
+ Victims of crime
+ Mental capacity and the law
+Education
+ School admissions
+ Schools
+ Special educational needs
+ Student money
+ Further and higher education
+ Adult learning
+ Libraries
+Work
+ Finding work
+ Starting work
+ Types of employment
+ Employment rights
+ Time off from work
+ Health and safety at work
+ Work-related benefits and schemes
+ Ending work
+Family
+ Maternity and paternity
+ Parenting
+ Adoption and fostering
+ Separation and divorce
+ Death and bereavement
+ Childcare
+ Registering life events
+ Marriage and civil partnership
+Money and tax
+ Children
+ Home
+ Sickness, disability and carers
+ Tax credits
+ Pensions
+ Debt and bankruptcy
+ Tax
+ Seasonal payments
+Driving
+ Learning to drive
+ Your driving licence
+ Vehicle tax
+ Buying/selling a vehicle
+ MOT
+ Owning a car/motorbike
+ Driving and your neighbourhood
+ Driving and the law
+ Driving courses
+Housing
+ Emergency housing
+ Council Tax
+ Council housing
+ Local council services
+ Housing problems and issues
+ Housing benefits, grants and schemes
+ Planning and building
+ Refuse and disposal
+ Your home
+ Buying and selling a home
+ Renting a home
+Life in the UK
+ The monarchy
+ How government works
+ Voting
+ Becoming a British citizen
+Travel
+ Foreign travel
+ Air travel
+ Passports
+ Animals and the UK
+ Moving and living abroad
+ Travelling in the UK
+Neighbourhoods
+ Community
+ Library and learning
+ Charities and volunteering
+ Council services
+ Reporting a problem
+ Open spaces
+ Your local area
View
2  app/views/artefacts/_form.html.erb
@@ -7,7 +7,7 @@
<%= f.inputs :name => "Basic information" do %>
<%= f.input :name %>
<%= f.input :slug %>
- <%= f.input :section, :as => :select, :collection => Artefact::SECTIONS %>
+ <%= f.input :section, :as => :select, :collection => Artefact.sections.map {|s| [s.gsub(':', ' > '), s] } %>
<% end %>
<%= f.inputs "Related items", :class => "related" do %>
<%= f.semantic_fields_for :related_items, related_items_for(artefact) do |related_item| %>
Please sign in to comment.
Something went wrong with that request. Please try again.