Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
Admin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
osuny
Admin
Commits
817e08fa
Commit
817e08fa
authored
3 years ago
by
pabois
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of github.com:noesya/osuny
parents
77ca6723
126a16a9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/models/communication/website/github_file.rb
+7
-1
7 additions, 1 deletion
app/models/communication/website/github_file.rb
app/models/communication/website/post.rb
+6
-0
6 additions, 0 deletions
app/models/communication/website/post.rb
with
13 additions
and
1 deletion
app/models/communication/website/github_file.rb
+
7
−
1
View file @
817e08fa
...
...
@@ -27,7 +27,7 @@ class Communication::Website::GithubFile < ApplicationRecord
after_destroy
:remove_from_github
def
publish
return
unless
github
.
valid?
return
unless
valid?
&&
github
.
valid?
add_to_batch
(
github
)
if
github
.
commit_batch
(
github_commit_message
)
update_column
:github_path
,
manifest_data
[
:generated_path
]
...
...
@@ -36,6 +36,7 @@ class Communication::Website::GithubFile < ApplicationRecord
handle_asynchronously
:publish
,
queue:
'default'
def
add_to_batch
(
github
)
return
unless
valid?
github
.
add_to_batch
github_params
add_media_to_batch
(
github
)
end
...
...
@@ -120,4 +121,9 @@ class Communication::Website::GithubFile < ApplicationRecord
item
[
:identifier
]
==
manifest_identifier
}
end
def
valid?
return
about
.
published?
if
about_type
==
'Communication::Website::Post'
true
end
end
This diff is collapsed.
Click to expand it.
app/models/communication/website/post.rb
+
6
−
0
View file @
817e08fa
...
...
@@ -55,6 +55,8 @@ class Communication::Website::Post < ApplicationRecord
validates
:title
,
presence:
true
validates
:slug
,
uniqueness:
{
scope: :communication_website_id
}
before_validation
:set_published_at
,
if: :published_changed?
scope
:ordered
,
->
{
order
(
published_at: :desc
,
created_at: :desc
)
}
scope
:recent
,
->
{
order
(
published_at: :desc
).
limit
(
5
)
}
...
...
@@ -72,4 +74,8 @@ class Communication::Website::Post < ApplicationRecord
def
slug_unavailable?
(
slug
)
self
.
class
.
unscoped
.
where
(
communication_website_id:
self
.
communication_website_id
,
slug:
slug
).
where
.
not
(
id:
self
.
id
).
exists?
end
def
set_published_at
self
.
published_at
=
published?
?
Time
.
zone
.
now
:
nil
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment