Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

組織名が特定可能な場合にテンプレートで取得できるようにする #163

Merged
merged 2 commits into from
May 16, 2024

Conversation

keita-yasuda
Copy link
Contributor

以下のテンプレート内で {% c.pkg_dict['organization']['name'] %} にて組織名を取得できるように修正。

  • management/comments.html
  • resource/comment.html
  • utilization/details.html
  • utilization/edit.html
  • utilization/new.html
  • utilization/search.html

※ 組織名取得元DBカラム:ckan.model.group.name

@keita-yasuda keita-yasuda changed the title Add organization name to global variables accessible from templates 組織名が特定可能な場合にテンプレートで取得できるようにする May 9, 2024
@@ -48,6 +48,24 @@ def search():
id, keyword, approval, admin_owner_orgs, org_name
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE: GETのクエリに含まれる idResource.id 又は Package.id である事が想定されている。

query = query.filter(or_(Resource.id == id, Package.id == id))

# set it as a global variable accessible from templates.
if id and not org_name:
resource = registration_service.get_resource(id)
package: model.Package
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

型定義のためかもしれませんが、代入もせずにぽつんと変数名だけがあるのはなかなか違和感のある記述ですね。
どこか参考にしたコードなどありますでしょうか?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

参考にしたコードはありません。
コードの文脈を意識して読みやすくするための記述のつもりでしたが、違和感をご指摘いただいたので削除いたします。

@keita-yasuda keita-yasuda marked this pull request as ready for review May 15, 2024 00:12
@ryo-ma ryo-ma merged commit 7b87958 into main May 16, 2024
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants