Project/platform management
This commit is contained in:
parent
7c39293855
commit
eccb4e0a6c
|
@ -6,10 +6,12 @@ class PlatformsController < ApplicationController
|
|||
end
|
||||
|
||||
def show
|
||||
@platform = Platform.find params[:id]
|
||||
@platform = Platform.find params[:id], :include => :projects
|
||||
@projects = @platform.projects
|
||||
end
|
||||
|
||||
def new
|
||||
@platforms = Platform.all
|
||||
@platform = Platform.new
|
||||
end
|
||||
|
||||
|
|
|
@ -1,2 +1,25 @@
|
|||
class ProjectsController < ApplicationController
|
||||
before_filter :authenticate_user!
|
||||
before_filter :find_platform
|
||||
|
||||
def new
|
||||
@project = @platform.projects.new
|
||||
end
|
||||
|
||||
def create
|
||||
@project = @platform.projects.new params[:project]
|
||||
if @project.save
|
||||
flash[:notice] = t('flash.project.saved')
|
||||
redirect_to @platform
|
||||
else
|
||||
flash[:error] = t('flash.project.save_error')
|
||||
render :action => :new
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def find_platform
|
||||
@platform = Platform.find params[:platform_id]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,18 +3,14 @@ class Platform < ActiveRecord::Base
|
|||
has_one :parent, :class_name => 'Platform', :foreign_key => 'parent_platform_id'
|
||||
|
||||
validate :name, :presence => true, :uniqueness => true
|
||||
validate :unixname, :presence => true, :uniqueness => true
|
||||
validate :validate_unixname
|
||||
validate :unixname, :uniqueness => true, :presence => true, :format => { :with => /^[a-zA-Z0-9\-.]+$/ }, :allow_nil => false, :allow_blank => false
|
||||
|
||||
before_validation :generate_unixname
|
||||
|
||||
protected
|
||||
|
||||
def generate_unixname
|
||||
#TODO: Implement unixname generation
|
||||
end
|
||||
|
||||
def validate_unixname
|
||||
#TODO: Implement unixname validation
|
||||
self.unixname = name.gsub(/[^a-zA-Z0-9\-.]/, '-')
|
||||
#TODO: Fix non-unique unixname
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
class Project < ActiveRecord::Base
|
||||
belongs_to :platform
|
||||
|
||||
validate :name, :uniqueness => true, :presence => true
|
||||
validate :unixname, :uniqueness => true, :presence => true
|
||||
validate :validate_unixname
|
||||
validate :name, :uniqueness => true, :presence => true, :allow_nil => false, :allow_blank => false
|
||||
validate :unixname, :uniqueness => true, :presence => true, :format => { :with => /^[a-zA-Z0-9\-.]+$/ }, :allow_nil => false, :allow_blank => false
|
||||
|
||||
before_validation :generate_unixname
|
||||
|
||||
include Project::HasRepository
|
||||
|
||||
# Redefining a method from Project::HasRepository module to reflect current situation
|
||||
def git_repo_path
|
||||
@git_repo_path ||= File.join(APP_CONFIG['root_path'], platform.unixname, project.unixname, project.unixname + '.git')
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def generate_unixname
|
||||
#TODO: Implement unixname generation
|
||||
self.unixname = name.gsub(/[^a-zA-Z0-9\-.]/, '-')
|
||||
#TODO: Fix non-unique unixname
|
||||
end
|
||||
|
||||
def validate_unixname
|
||||
#TODO: Implement unixname validation
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -9,6 +9,6 @@ module Project::HasRepository
|
|||
|
||||
protected
|
||||
def git_repo_path
|
||||
@git_repo_path ||= "xxx"
|
||||
@git_repo_path ||= File.join(APP_CONFIG['root_path'], platform.unixname, project.unixname, project.unixname + '.git')
|
||||
end
|
||||
end
|
|
@ -1,7 +1,7 @@
|
|||
%h1= t('layout.platforms.list')
|
||||
- @platforms.each do |platform|
|
||||
= div_for platform do
|
||||
= platform.name
|
||||
= link_to platform.name, platform
|
||||
= link_to t('layout.platforms.new'), new_platform_path
|
||||
.div
|
||||
= link_to t('layout.user_list'), users_path
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
%h1= t('layout.platforms.new_header')
|
||||
= form_for @platform do |f|
|
||||
%p
|
||||
= f.label :name
|
||||
= f.text_field :name
|
||||
%p
|
||||
= f.label :parent_platform_id
|
||||
= f.select :parent_platform_id, @platforms.map { |p| [p.name, p.id] }, :include_blank => true
|
||||
%p
|
||||
= f.submit t('layout.create')
|
||||
= link_to t('layout.cancel'), platforms_path
|
|
@ -0,0 +1,11 @@
|
|||
%h1
|
||||
= t('layout.platforms.show')
|
||||
= @platform.name
|
||||
|
||||
%h2= t('layout.platforms.projects')
|
||||
- @projects.each do |project|
|
||||
= div_for project do
|
||||
= link_to project.name, [@platform, project]
|
||||
= link_to t('layout.projects.new'), new_platform_project_path(@platform)
|
||||
|
||||
%h2= t('layout.platforms.products')
|
|
@ -0,0 +1,8 @@
|
|||
%h1= t('layout.projects.new')
|
||||
= form_for [@platform, @project] do |f|
|
||||
%p
|
||||
= f.label :name
|
||||
= f.text_field :name
|
||||
%p
|
||||
= f.submit t('layout.create')
|
||||
= link_to t('layout.cancel'), platform_path(@platform)
|
|
@ -4,10 +4,26 @@ ru:
|
|||
logged_in_as: Вы вошли как
|
||||
logout: Выйти
|
||||
user_list: Список пользователей
|
||||
cancel: Отмена
|
||||
create: Создать
|
||||
save: Сохранить
|
||||
platforms:
|
||||
list: Платформы
|
||||
new: Создать новую платформу
|
||||
new_header: Новая платформа
|
||||
show: Платформа
|
||||
projects: Проекты
|
||||
products: Продукты
|
||||
projects:
|
||||
new: Новый проект
|
||||
|
||||
flash:
|
||||
project:
|
||||
saved: Проект успешно сохранен
|
||||
save_error: Не удалось сохранить проект
|
||||
|
||||
attributes:
|
||||
password: Пароль
|
||||
remember_me: Запомнить
|
||||
name: Название
|
||||
parent_platform_id: Родительская платформа
|
||||
|
|
Loading…
Reference in New Issue