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
a162615b
Commit
a162615b
authored
1 year ago
by
Arnaud Levy
Browse files
Options
Downloads
Patches
Plain Diff
wip
parent
9728fc23
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/controllers/api/osuny/application_controller.rb
+6
-0
6 additions, 0 deletions
app/controllers/api/osuny/application_controller.rb
app/controllers/api/osuny/communication/websites/posts_controller.rb
+19
-12
19 additions, 12 deletions
...lers/api/osuny/communication/websites/posts_controller.rb
with
25 additions
and
12 deletions
app/controllers/api/osuny/application_controller.rb
+
6
−
0
View file @
a162615b
class
Api::Osuny::ApplicationController
<
Api
::
ApplicationController
protected
def
verify_app_token
...
...
@@ -6,4 +7,9 @@ class Api::Osuny::ApplicationController < Api::ApplicationController
secret_key:
params
[
:secret_key
])
raise_403_unless
app
end
def
website
@website
||=
current_university
.
websites
.
find
params
[
:website_id
]
end
end
\ No newline at end of file
This diff is collapsed.
Click to expand it.
app/controllers/api/osuny/communication/websites/posts_controller.rb
+
19
−
12
View file @
a162615b
...
...
@@ -5,6 +5,7 @@ class Api::Osuny::Communication::Websites::PostsController < Api::Osuny::Applica
verify_app_token
create_post
import_blocks
import_categories
render
json: :ok
end
...
...
@@ -16,16 +17,6 @@ class Api::Osuny::Communication::Websites::PostsController < Api::Osuny::Applica
post
.
save
end
def
post
@post
||=
website
.
posts
.
where
(
university:
current_university
,
website:
website
,
migration_identifier:
migration_identifier
)
.
first_or_initialize
end
def
import_blocks
blocks
.
each
do
|
b
|
migration_identifier
=
b
[
:migration_identifier
]
...
...
@@ -43,13 +34,29 @@ class Api::Osuny::Communication::Websites::PostsController < Api::Osuny::Applica
end
end
def
import_categories
categories
.
each
do
|
category
|
byebug
end
end
def
post
@post
||=
website
.
posts
.
where
(
university:
current_university
,
website:
website
,
migration_identifier:
migration_identifier
)
.
first_or_initialize
end
def
blocks
return
[]
unless
params
[
:post
].
has_key?
(
:blocks
)
@blocks
||=
params
[
:post
][
:blocks
]
end
def
website
@website
||=
current_university
.
websites
.
find
params
[
:website_id
]
def
categories
return
[]
unless
params
[
:post
].
has_key?
(
:categories
)
@categories
||=
params
[
:post
][
:categories
]
end
def
migration_identifier
...
...
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