From 505797d7ae46aaba0cde9fefa937919c4618eeb3 Mon Sep 17 00:00:00 2001 From: "sylor_huang@126.com" Date: Fri, 20 Mar 2020 17:35:11 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=A2=9E=E5=8A=A0journal=E7=9A=84json?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/journals/_journal_item.json.jbuilder | 16 ++++++++++++++++ app/views/journals/edit.json.jbuilder | 2 ++ app/views/journals/index.json.jbuilder | 8 ++++++++ app/views/journals/update.json.jbuilder | 0 4 files changed, 26 insertions(+) create mode 100644 app/views/journals/_journal_item.json.jbuilder create mode 100644 app/views/journals/edit.json.jbuilder create mode 100644 app/views/journals/index.json.jbuilder create mode 100644 app/views/journals/update.json.jbuilder diff --git a/app/views/journals/_journal_item.json.jbuilder b/app/views/journals/_journal_item.json.jbuilder new file mode 100644 index 000000000..03fd35c7b --- /dev/null +++ b/app/views/journals/_journal_item.json.jbuilder @@ -0,0 +1,16 @@ +json.id journal.id +json.user_name journal.user.try(:show_real_name) +json.user_login journal.user.try(:login) +json.user_picture url_to_avatar(journal.user) +json.is_journal_detail journal.is_journal_detail? #判断是否修改了参数而添加的回复内容 +json.content journal.try(:notes) +json.children_journals children_content(journal.id) +json.journal_details journal.journal_content +json.format_time format_time(journal.created_on) +json.created_at time_from_now(journal.created_on) + +json.attachments do + json.array! journal.attachments do |attachment| + json.partial! "attachments/attachment_simple", locals: {attachment: attachment} + end +end \ No newline at end of file diff --git a/app/views/journals/edit.json.jbuilder b/app/views/journals/edit.json.jbuilder new file mode 100644 index 000000000..f5460ded4 --- /dev/null +++ b/app/views/journals/edit.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! @journal, :id,:notes +json.issue_id @journal.journalized_id \ No newline at end of file diff --git a/app/views/journals/index.json.jbuilder b/app/views/journals/index.json.jbuilder new file mode 100644 index 000000000..2485e72bd --- /dev/null +++ b/app/views/journals/index.json.jbuilder @@ -0,0 +1,8 @@ +json.partial! "commons/success" +json.limit @limit +json.journals_count @journals_size +json.issue_journals do + json.array! @journals do |journal| + json.partial! "journals/journal_item", journal: journal + end +end \ No newline at end of file diff --git a/app/views/journals/update.json.jbuilder b/app/views/journals/update.json.jbuilder new file mode 100644 index 000000000..e69de29bb From 157465966794425bd0ed7b0482e0a935992680a3 Mon Sep 17 00:00:00 2001 From: "sylor_huang@126.com" Date: Fri, 20 Mar 2020 18:14:22 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=B5=8B=E8=AF=95entries?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/repositories_controller.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index e0d65a3a5..dd5ce62cc 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -15,9 +15,15 @@ class RepositoriesController < ApplicationController end def entries + Rails.logger.info("##############_________project_id_________############{@project.id}") @project.increment!(:visits) + Rails.logger.info("##############___________@repo.identifier_______############{@repo.identifier}") + Rails.logger.info("##############___________@user_______############{@user.login}") + @ref = params[:branch] || "master" @entries = Gitea::Repository::Entries::ListService.new(@user, @repo.identifier, ref:@ref).call + Rails.logger.info("##############__________@entries______############{@entries}") + @entries = @entries.sort_by{ |hash| hash['type'] } end From a72675cf1aadba598b98a44dce5db1e802d9cb25 Mon Sep 17 00:00:00 2001 From: "sylor_huang@126.com" Date: Fri, 20 Mar 2020 18:30:35 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E8=AF=84=E8=AE=BA=E4=B8=8D=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E7=9A=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/attachment.rb | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 3ff9a6a90..553c1daf2 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -38,14 +38,15 @@ class Attachment < ApplicationRecord end def title - title = filename - if container && container.is_a?(StudentWork) && author_id != User.current.id - course = container&.homework_common&.course - unless User.current.teacher_of_course?(course) - title = "#{Time.now.strftime('%Y%m%d%H%M%S')}_#{DCODES.sample(8).join}" + File.extname(filename) - end - end - title + filename + # title = filename + # if container && container.is_a?(StudentWork) && author_id != User.current.id + # course = container&.homework_common&.course + # unless User.current.teacher_of_course?(course) + # title = "#{Time.now.strftime('%Y%m%d%H%M%S')}_#{DCODES.sample(8).join}" + File.extname(filename) + # end + # end + # title end def downloads_count