<commit_before>#encoding: utf-8
require 'rubygems'
require 'sinatra'
require 'sinatra/reloader'
require 'sinatra/activerecord'

set :database, "sqlite3:barbershop.db"

class Client < ActiveRecord::Base
	validates :name, presence: true, length: { minimum: 3 }
	validates :phone, presence: true, length: { minimum: 6 }
	validates :barber, presence: true
	validates :datestamp, presence: true
	validates :color, presence: true   
end

class Barber < ActiveRecord::Base
end

class Contact < ActiveRecord::Base
	validates :email, presence: true, length: { minimum: 4 }
	validates :contact, presence: true, length: { minimum: 2 }
end

before do
	@barbers = Barber.all
	@clients = Client.all
	@contacts = Contact.all
end

get '/' do
	erb :index
end

get '/visit' do
	@appointment = { :name => '', :phone => '', :datestamp => '', :barber => '', :color => '', :email => '', :text => '' }
	erb :visit
end

post '/visit' do
	@appointment = Client.new params[:client]
	
	# @client_name = params[:client_name]
	# @client_phone = params[:client_phone]
	# ...
	
	# Client.create :name => @client_name, :phone => @client_phone, :datestamp => @datetime, :barber => @barber, :color => @color
	
	# OR
	
	# c = Client.new
	# c.name = @client_name
	# ...
	# c.save
	if @appointment.save
		erb "Спасибо! #{@appointment[:name].capitalize}, мы будем ждать Вас #{@appointment[:datestamp]}"
	else
		erb "Для записи необходимо заполнить все поля."
	end
end

get '/contacts' do
	@contact = { :email => '', :contact => '' }
	erb :contacts
end

post '/contacts' do
	@contact = Contact.new params[:client]
	@contact.save

	erb "Спасибо! Мы напишем Вам ответ на адрес #{@contact[:email]}"
end

get '/about' do
	erb :about
end<commit_msg>Display error text in visit.erb<commit_after>#encoding: utf-8
require 'rubygems'
require 'sinatra'
require 'sinatra/reloader'
require 'sinatra/activerecord'

set :database, "sqlite3:barbershop.db"

class Client < ActiveRecord::Base
	validates :name, presence: true, length: { minimum: 3 }
	validates :phone, presence: true, length: { minimum: 6 }
	validates :barber, presence: true
	validates :datestamp, presence: true
	validates :color, presence: true   
end

class Barber < ActiveRecord::Base
end

class Contact < ActiveRecord::Base
	validates :email, presence: true, length: { minimum: 4 }
	validates :contact, presence: true, length: { minimum: 2 }
end

before do
	@barbers = Barber.all
	@clients = Client.all
	@contacts = Contact.all
end

get '/' do
	erb :index
end

get '/visit' do
	@appointment = { :name => '', :phone => '', :datestamp => '', :barber => '', :color => '', :email => '', :text => '' }
	erb :visit
end

post '/visit' do
	@appointment = Client.new params[:client]
	
	# @client_name = params[:client_name]
	# @client_phone = params[:client_phone]
	# ...
	
	# Client.create :name => @client_name, :phone => @client_phone, :datestamp => @datetime, :barber => @barber, :color => @color
	
	# OR
	
	# c = Client.new
	# c.name = @client_name
	# ...
	# c.save
	if @appointment.save
		erb "Спасибо! #{@appointment[:name].capitalize}, мы будем ждать Вас #{@appointment[:datestamp]}"
	else
		@error = @appointment.errors.full_messages.first
		erb :visit
	end
end

get '/contacts' do
	@contact = { :email => '', :contact => '' }
	erb :contacts
end

post '/contacts' do
	@contact = Contact.new params[:client]
	@contact.save

	erb "Спасибо! Мы напишем Вам ответ на адрес #{@contact[:email]}"
end

get '/about' do
	erb :about
end
{'fraction_non_alphanumeric': 0.15659500290528763, 'fraction_numerical': 0.003486345148169669, 'mean_word_length': 4.313271604938271, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1800478', 'n_tokens_mistral': 1268, 'n_tokens_neox': 1232, 'n_words': 344}