[FIX]merge
This commit is contained in:
commit
d42053ce0c
|
@ -0,0 +1,16 @@
|
||||||
|
class ApplySignaturesController < ApplicationController
|
||||||
|
def create
|
||||||
|
ActiveRecord::Base.transaction do
|
||||||
|
begin
|
||||||
|
@signature = current_user.apply_signatures.create!(project_id: params[:project_id])
|
||||||
|
@attachment = Attachment.find_by_id(params[:attachment_id])
|
||||||
|
@attachment.container = @signature
|
||||||
|
@attachment.save!
|
||||||
|
rescue Exception => e
|
||||||
|
tip_exception("#{e}")
|
||||||
|
raise ActiveRecord::Rollback
|
||||||
|
end
|
||||||
|
render_json
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -53,7 +53,7 @@ class ProjectsController < ApplicationController
|
||||||
# else
|
# else
|
||||||
# projects = Project.visible
|
# projects = Project.visible
|
||||||
# end
|
# end
|
||||||
projects = Project.no_anomory_projects.visible
|
projects = Project.no_anomory_projects.secret_and_visible
|
||||||
language_lists = projects.joins(:project_language).group("project_languages.name", "project_languages.id").size.keys.sort.to_h
|
language_lists = projects.joins(:project_language).group("project_languages.name", "project_languages.id").size.keys.sort.to_h
|
||||||
@project_group_list = language_lists.delete_if { |k, v| k.blank? }
|
@project_group_list = language_lists.delete_if { |k, v| k.blank? }
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
class ApplySignature < ApplicationRecord
|
||||||
|
belongs_to :user
|
||||||
|
belongs_to :project
|
||||||
|
|
||||||
|
scope :with_user_id, -> (user_id) {where(user_id: user_id)}
|
||||||
|
end
|
|
@ -11,4 +11,6 @@
|
||||||
|
|
||||||
class License < ApplicationRecord
|
class License < ApplicationRecord
|
||||||
include Projectable
|
include Projectable
|
||||||
|
has_many :attachments, as: :container, dependent: :destroy
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -106,12 +106,16 @@ class Project < ApplicationRecord
|
||||||
has_many :praise_treads, as: :praise_tread_object, dependent: :destroy
|
has_many :praise_treads, as: :praise_tread_object, dependent: :destroy
|
||||||
has_and_belongs_to_many :trackers, :order => "#{Tracker.table_name}.position"
|
has_and_belongs_to_many :trackers, :order => "#{Tracker.table_name}.position"
|
||||||
has_one :project_detail, dependent: :destroy
|
has_one :project_detail, dependent: :destroy
|
||||||
|
has_many :apply_signatures, dependent: :destroy
|
||||||
|
|
||||||
after_save :check_project_members
|
after_save :check_project_members
|
||||||
scope :project_statics_select, -> {select(:id,:name, :is_public, :identifier, :status, :project_type, :user_id, :forked_count, :visits, :project_category_id, :project_language_id, :license_id, :ignore_id, :watchers_count, :created_on)}
|
scope :project_statics_select, -> {select(:id,:name, :is_public, :identifier, :status, :project_type, :user_id, :forked_count, :visits, :project_category_id, :project_language_id, :license_id, :ignore_id, :watchers_count, :created_on)}
|
||||||
scope :no_anomory_projects, -> {where("projects.user_id is not null and projects.user_id != ?", 2)}
|
scope :no_anomory_projects, -> {where("projects.user_id is not null and projects.user_id != ?", 2)}
|
||||||
scope :recommend, -> { visible.project_statics_select.where(recommend: true) }
|
scope :recommend, -> { visible.project_statics_select.where(recommend: true) }
|
||||||
|
|
||||||
|
scope :secret_and_visible, -> {joins(:license).where("licenses.is_secret = TRUE OR projects.is_public = TRUE")}
|
||||||
|
|
||||||
|
delegate :is_secret, to: :license
|
||||||
|
|
||||||
|
|
||||||
def self.search_project(search)
|
def self.search_project(search)
|
||||||
|
|
|
@ -161,6 +161,7 @@ class User < ApplicationRecord
|
||||||
# has_many :libraries, dependent: :destroy
|
# has_many :libraries, dependent: :destroy
|
||||||
has_many :project_trends, dependent: :destroy
|
has_many :project_trends, dependent: :destroy
|
||||||
has_many :oauths , dependent: :destroy
|
has_many :oauths , dependent: :destroy
|
||||||
|
has_many :apply_signatures, dependent: :destroy
|
||||||
|
|
||||||
# Groups and active users
|
# Groups and active users
|
||||||
scope :active, lambda { where(status: STATUS_ACTIVE) }
|
scope :active, lambda { where(status: STATUS_ACTIVE) }
|
||||||
|
|
|
@ -10,7 +10,7 @@ class Projects::ListQuery < ApplicationQuery
|
||||||
end
|
end
|
||||||
|
|
||||||
def call
|
def call
|
||||||
q = Project.visible.by_name_or_identifier(params[:search])
|
q = Project.secret_and_visible.by_name_or_identifier(params[:search])
|
||||||
|
|
||||||
scope = q
|
scope = q
|
||||||
.with_project_type(params[:project_type])
|
.with_project_type(params[:project_type])
|
||||||
|
|
|
@ -53,6 +53,11 @@ class Projects::CreateService < ApplicationService
|
||||||
# end
|
# end
|
||||||
|
|
||||||
def repo_is_public
|
def repo_is_public
|
||||||
|
license = License.find_by_id(params[:license_id])
|
||||||
|
if license.is_secret
|
||||||
|
false
|
||||||
|
else
|
||||||
params[:private].blank? ? true : !params[:private]
|
params[:private].blank? ? true : !params[:private]
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
json.id @signature.id
|
||||||
|
json.attachment do
|
||||||
|
json.name @attachment.filename
|
||||||
|
end
|
|
@ -1 +1 @@
|
||||||
json.licenses @licenses, :id, :name
|
json.licenses @licenses, :id, :name, :is_secret
|
||||||
|
|
|
@ -7,6 +7,7 @@ json.visits project.visits
|
||||||
json.praises_count project.praises_count.to_i
|
json.praises_count project.praises_count.to_i
|
||||||
json.forked_count project.forked_count.to_i
|
json.forked_count project.forked_count.to_i
|
||||||
json.is_public project.is_public
|
json.is_public project.is_public
|
||||||
|
json.is_secret project.is_secret
|
||||||
json.mirror_url project.repository&.mirror_url
|
json.mirror_url project.repository&.mirror_url
|
||||||
json.type project&.numerical_for_project_type
|
json.type project&.numerical_for_project_type
|
||||||
json.last_update_time render_unix_time(project.updated_on)
|
json.last_update_time render_unix_time(project.updated_on)
|
||||||
|
@ -35,12 +36,25 @@ json.category do
|
||||||
json.id project.project_category.id
|
json.id project.project_category.id
|
||||||
json.name project.project_category.name
|
json.name project.project_category.name
|
||||||
end
|
end
|
||||||
end
|
json.category do
|
||||||
json.language do
|
if project.project_category.blank?
|
||||||
|
json.nil!
|
||||||
|
else
|
||||||
|
json.id project.project_category.id
|
||||||
|
json.name project.project_category.name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
json.language do
|
||||||
if project.project_language.blank?
|
if project.project_language.blank?
|
||||||
json.nil!
|
json.nil!
|
||||||
else
|
else
|
||||||
json.id project.project_language.id
|
json.id project.project_language.id
|
||||||
json.name project.project_language.name
|
json.name project.project_language.name
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
user_apply_signatures = project.apply_signatures.with_user_id(current_user.id)
|
||||||
|
json.user_apply_signatures user_apply_signatures do |signature|
|
||||||
|
json.id signature.id
|
||||||
|
json.status signature.status
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
json.name @project.name
|
json.name @project.name
|
||||||
json.identifier @project.identifier
|
json.identifier @project.identifier
|
||||||
json.is_public @project.is_public
|
json.is_public @project.is_public
|
||||||
|
json.is_secret @project.is_secret
|
||||||
json.description @project.description
|
json.description @project.description
|
||||||
json.repo_id @project.repository.id
|
json.repo_id @project.repository.id
|
||||||
json.repo_identifier @project.repository.identifier
|
json.repo_identifier @project.repository.identifier
|
||||||
|
user_apply_signatures = @project.apply_signatures.with_user_id(current_user.id)
|
||||||
|
json.user_apply_signatures user_apply_signatures do |signature|
|
||||||
|
json.id signature.id
|
||||||
|
json.status signature.status
|
||||||
|
end
|
|
@ -5,3 +5,4 @@ json.project_description @project.description
|
||||||
json.project_category_id @project.project_category_id
|
json.project_category_id @project.project_category_id
|
||||||
json.project_language_id @project.project_language_id
|
json.project_language_id @project.project_language_id
|
||||||
json.private !@project.is_public
|
json.private !@project.is_public
|
||||||
|
json.is_secret @project.is_secret
|
||||||
|
|
|
@ -17,6 +17,12 @@ json.mirror_url @project&.repository.mirror_url
|
||||||
json.mirror @project&.repository.mirror_url.present?
|
json.mirror @project&.repository.mirror_url.present?
|
||||||
json.type @project.numerical_for_project_type
|
json.type @project.numerical_for_project_type
|
||||||
json.open_devops @project.open_devops?
|
json.open_devops @project.open_devops?
|
||||||
|
json.is_secret @project.is_secret
|
||||||
|
user_apply_signatures = @project.apply_signatures.with_user_id(current_user.id)
|
||||||
|
json.user_apply_signatures user_apply_signatures do |signature|
|
||||||
|
json.id signature.id
|
||||||
|
json.status signature.status
|
||||||
|
end
|
||||||
|
|
||||||
unless @project.common?
|
unless @project.common?
|
||||||
json.mirror_status @repo.mirror_status
|
json.mirror_status @repo.mirror_status
|
||||||
|
|
|
@ -59,6 +59,7 @@ Rails.application.routes.draw do
|
||||||
delete :destroy_files
|
delete :destroy_files
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
resources :apply_signatures, only: [:create]
|
||||||
get 'home/index'
|
get 'home/index'
|
||||||
get 'home/search'
|
get 'home/search'
|
||||||
get 'main/first_stamp'
|
get 'main/first_stamp'
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
class CreateApplySignatures < ActiveRecord::Migration[5.2]
|
||||||
|
def change
|
||||||
|
create_table :apply_signatures do |t|
|
||||||
|
t.references :user
|
||||||
|
t.references :project
|
||||||
|
t.integer :status, default: 0
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,6 @@
|
||||||
|
class AddSomeColumnsAboutApplySignatures < ActiveRecord::Migration[5.2]
|
||||||
|
def change
|
||||||
|
add_column :licenses, :is_secret, :boolean, default: false
|
||||||
|
add_column :members, :is_apply_signature, :boolean, default: false
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,5 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe ApplySignature, type: :model do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
Loading…
Reference in New Issue