Skip to content
This repository has been archived by the owner on Oct 12, 2018. It is now read-only.

Commit

Permalink
Allow classification into subsections.
Browse files Browse the repository at this point in the history
  • Loading branch information
heathd committed Jan 18, 2012
1 parent f4266b2 commit 94cf253
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 13 deletions.
27 changes: 15 additions & 12 deletions 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",
Expand Down
89 changes: 89 additions & 0 deletions 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
2 changes: 1 addition & 1 deletion app/views/artefacts/_form.html.erb
Expand Up @@ -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| %>
Expand Down

0 comments on commit 94cf253

Please sign in to comment.