Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
Cleanups and provide more mailer functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandermeindl committed May 30, 2022
1 parent d9a6e42 commit 55312e4
Show file tree
Hide file tree
Showing 22 changed files with 147 additions and 22 deletions.
8 changes: 5 additions & 3 deletions app/controllers/dashboards_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ def show
end

def new
@dashboard = Dashboard.new(project: @project,
author: User.current)
@dashboard = Dashboard.new project: @project,
author: User.current
@dashboard.dashboard_type = assign_dashboard_type
@allowed_projects = @dashboard.allowed_target_projects
end
Expand Down Expand Up @@ -101,11 +101,13 @@ def edit
def update
return render_403 unless @dashboard.editable?

# should be set before dashboar object has modified
@allowed_projects = @dashboard.allowed_target_projects

@dashboard.safe_attributes = params[:dashboard]
@dashboard.role_ids = params[:dashboard][:role_ids] if params[:dashboard].present?

@project = @dashboard.project if @project && @dashboard.project_id.present? && @dashboard.project != @project
@allowed_projects = @dashboard.allowed_target_projects

if @dashboard.save
flash[:notice] = l :notice_successful_update
Expand Down
4 changes: 3 additions & 1 deletion app/models/dashboard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,9 @@ def css_classes(user = User.current)
end

def allowed_target_projects(user = User.current)
Project.where Project.allowed_to_condition(user, :save_dashboards)
self.class.allowed_entity_target_projects user: user,
permission: :save_dashboards,
project: project
end

# this is used to get unique cache for blocks
Expand Down
5 changes: 1 addition & 4 deletions app/views/dashboards/_form.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,12 @@
= hidden_field_tag 'dashboard[content_project_id]', @project.id
- if @allowed_projects.present? && @allowed_projects.count > 1
p
= hidden_field_tag 'dashboard[content_project_id]', @project&.id
= f.select :project_id,
project_tree_options_for_select(@allowed_projects,
selected: @dashboard.project,
include_blank: true),
include_blank: "<< #{l :label_all_projects}>>"),
{},
disabled: [email protected]_id_can_change?
em.info
= l :info_dashboard_project_select
- else
= hidden_field_tag 'dashboard[project_id]', @project.id

Expand Down
2 changes: 1 addition & 1 deletion app/views/dashboards/new.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ h2 = l :label_new_dashboard
url: { action: 'create', project_id: @project },
html: { multipart: true, id: 'dashboard-form' } do |f|
= render partial: 'form', locals: { f: f }
= submit_tag l(:button_save)
= submit_tag l(:button_create)
17 changes: 17 additions & 0 deletions app/views/mailer/_entity.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
hr

h1 = link_to h(title), entity_url

= render_email_attributes entity, html: true

= textilizable entity, content_field, only_path: false

- if with_attachments && entity.attachments.any?
fieldset.attachments
legend = l :label_attachment_plural
- entity.attachments.each do |attachment|
= link_to_attachment attachment, download: true, only_path: false
| (
= number_to_human_size attachment.filesize
| )
br
15 changes: 15 additions & 0 deletions app/views/mailer/_entity.text.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

----------------------------------------
<%= title %>
<%= entity_url %>

<%= render_email_attributes entity %>
----------------------------------------
<%= entity.send content_field %>

<% if with_attachments && entity.attachments.any? -%>
---<%= l(:label_attachment_plural).ljust(37, '-') %>
<% entity.attachments.each do |attachment| -%>
<%= attachment.filename %> (<%= number_to_human_size attachment.filesize %>)
<% end -%>
<% end -%>
2 changes: 1 addition & 1 deletion config/locales/cs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ cs:
global_wiki_sidebar_info: 'Zde zadejte textovou textovou zprávu, která je k dispozici pro váš postranní panel wiki. Tento text postranního panelu se zobrazí pouze na stránkách wiki. Tento prostor použijte například pro makra, například „Last changed pages“. V případě, že je použit boční panel specifický pro projekt (wiki stránka), bude to místo toho zobrazen na postranním panelu.'
google_maps_embed_api_html: "V případě, že chcete k zobrazení map Goole použít makro Gmap, implementujte zde klíč API Google Maps API. Poté můžete použít makro a různé parametry. Více informací o tom, jak používat parametry, naleznete na <a href=\"https://developers.google.com/maps/documentation/embed/guide\" target=\"_blank\">https://developers.google.com/maps/documentation/embed/guide</a>. Makro Gmap zde funguje pouze v kombinaci s vloženým klíčem."
hidden_macros_in_toolbar_info: "Všechna dostupná makra, která může přihlášený uživatel použít, jsou uvedena prostřednictvím tlačítka makro na panelu nástrojů wiki. Makra zde označená nejsou nabízena k výběru. To vám umožní omezit rozsah seznamu."
info_dashboard_project_select: Leave it blank, if you want to use this dashboard for all projects.
info_hidden_roles_html: "Skryté role lze použít pouze spolu s viditelností uživatele \"Members of visible projects\". Pokud uživatel není v roli, která je viditelná pro aktuálního uživatele, je tato role včetně uživatele skryta na stránce s přehledem projektu a v seznamech dotazů."
info_live_search_result_restriction: "Výsledky vyhledávání LiveSearch jsou omezeny na %{value} zásahy. Zkuste své hledání popsat podrobněji."
label_account_login_bottom: "Text pro přihlašovací stránku"
Expand Down Expand Up @@ -195,3 +194,4 @@ cs:
label_help_doc: Dokumentace
label_activate_quickstart: Aktivovat quickstart
label_quickstart: Quickstart
label_all_projects: All projects
2 changes: 1 addition & 1 deletion config/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ de:
global_wiki_sidebar_info: 'Hier kann für die Wiki Sidebar ein projektübergreifender Text hinterlegt werden. Diese Sidebar wird nur auf den Wiki Seiten angezeigt und kann z.B. für Makros wie "Zuletzt geänderte Seiten" verwendet werden. Wird eine projektspezifische Sidebar angelegt (über eine Wiki Seite), dann wird diese anstelle der projektübergreifenden Sidebar angezeigt.'
google_maps_embed_api_html: Wenn Du das Gmap Makro verwenden willst um Google Karten darzustellen, musst Du hier Deinen Google Maps Embed API Schlüssel eintragen. Mehr Informationen dazu findest Du unter <a href="https://developers.google.com/maps/documentation/embed/guide" target="_blank">https://developers.google.com/maps/documentation/embed/guide</a>. Wird hier kein Schlüssel eingetragen, kann das gmap Makro nicht verwendet werden.
hidden_macros_in_toolbar_info: Alle verfügbaren Makros, die der angemeldete Benutzer verwenden kann, werden über den Makro-Button der Wiki-Toolbar aufgelistet. Hier markierte Makros werden nicht zur Auswahl angeboten. Damit lässt sich der Listenumfang einschränken.
info_dashboard_project_select: Wird hier kein Projekt angegeben, ist dieses Dashboard für alle Projekte verfügbar.
info_hidden_roles_html: Versteckte Rollen können nur zusammen mit der Benutzersichtbarkeit "Mitglieder von sichtbaren Projekten" verwendet werden. Diese Option funktioniert nur, wenn der Benutzer in keiner Rolle ist die für den aktuellen Benutzer sichtbar ist. Passt alles wird diese Rolle inklusive Benutzer auf der Projektübersichtsseite und in Abfragelisten ausgeblendet.
info_live_search_result_restriction: LiveSearch Ergebnisse sind auf %{value} Treffer begrenzt. Versuche Deine Suche genauer zu beschreiben.
label_account_login_bottom: "Text für Anmeldeseite"
Expand Down Expand Up @@ -195,3 +194,4 @@ de:
label_help_doc: Dokumentation
label_activate_quickstart: Schnellstart aktivieren
label_quickstart: Schnellstart
label_all_projects: Alle Projekte
2 changes: 1 addition & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ en:
global_wiki_sidebar_info: 'Enter a project wide available text message for your wiki sidebar, here. This sidebar text will be displayed at the wiki pages only. Use this space for Macros like "Last changed pages" for example. In case a project specific sidebar is used (wiki page), this will be preferably displayed in the sidebar instead.'
google_maps_embed_api_html: In case you want to use the Gmap macro in order to display Goole maps please implement your Google Maps API key here. Afterwards you can use the macro and various paramters. More information on how to use the paramaters are provided at <a href="https://developers.google.com/maps/documentation/embed/guide" target="_blank">https://developers.google.com/maps/documentation/embed/guide</a>. The Gmap macro works only in combination with the embedded key here.
hidden_macros_in_toolbar_info: All available macros that the logged in user can use are listed via the macro button of the wiki toolbar. Macros marked here are not offered for selection. This allows you to limit the scope of the list.
info_dashboard_project_select: Leave it blank, if you want to use this dashboard for all projects.
info_hidden_roles_html: Hidden roles can only be used together with the user visibility "Members of visible projects". If the user is not in a role that is visible to the current user, this role including user is hidden on the project overview page and in query lists.
info_live_search_result_restriction: "LiveSearch results are limited to %{value} entries. Try to filter your search a better way."
label_account_login_bottom: "Text for login page"
Expand Down Expand Up @@ -195,3 +194,4 @@ en:
label_help_doc: Documentation
label_activate_quickstart: Activate quickstart
label_quickstart: Quickstart
label_all_projects: All projects
2 changes: 1 addition & 1 deletion config/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ es:
global_wiki_sidebar_info: 'Ingrese aquí un el texto a ser mostrado en la barra lateral de la Wiki. Esta barra lateral solo será mostrada en las Wiki. Puede utilizar este espacio para macros como "Últimas páginas modificadas". En caso de que se utilice una barra lateral de proyecto esté en uso, este texto será mostrado en su lugar.'
google_maps_embed_api_html: En caso de querer utilizar el macro Gmap para mostrar mapas de Google necesita ingresar su Clave de API de Google Maps aquí. Luego podrá utilizar el macro y varios parámetros. Mas información acerca de como utilizar estos parametros está disponible en <a href="https://developers.google.com/maps/documentation/embed/guide" target="_blank">https://developers.google.com/maps/documentation/embed/guide</a>. El macro Gmap funciona solamente si se ingresa esta clave.
hidden_macros_in_toolbar_info: Todas las macros disponibles que el usuario conectado puede utilizar se enumeran mediante el botón de macros de la barra de herramientas wiki. Las macros marcadas aquí no se ofrecen para la selección. Esto permite restringir el alcance de la lista.
info_dashboard_project_select: Leave it blank, if you want to use this dashboard for all projects.
info_hidden_roles_html: Los roles ocultos sólo se pueden utilizar junto con la visibilidad del usuario "Miembros de proyectos visibles". Si el usuario no está en una función que sea visible para el usuario actual, esta función, que incluye al usuario, se oculta en la página de resumen del proyecto y en las listas de consulta.
info_live_search_result_restriction: "Los resultados de LiveSearch se limitan a %{value} golpes. Intente describir su búsqueda con más detalle."
label_account_login_bottom: "Texto para la página de inicio de sesión"
Expand Down Expand Up @@ -195,3 +194,4 @@ es:
label_help_doc: "Documentación"
label_activate_quickstart: Activar quickstart
label_quickstart: Quickstart
label_all_projects: All projects
2 changes: 1 addition & 1 deletion config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ fr:
global_wiki_sidebar_info: "Entrez ici un message texte disponible pour l'ensemble du projet pour votre barre latérale wiki. Ce texte de la barre latérale sera affiché uniquement sur les pages wiki. Use this space for Macros like \"Last changed pages\" for example. Dans le cas où une barre latérale spécifique au projet est utilisée (page wiki), celle-ci sera de préférence affichée dans la barre latérale."
google_maps_embed_api_html: "Si vous souhaitez utiliser la macro Gmap pour afficher les cartes de Goole, veuillez implémenter votre clé API Google Maps ici. Ensuite, vous pouvez utiliser la macro et divers paramètres. Pour plus d'informations sur l'utilisation des paramètres, voir <a href=\"https://developers.google.com/maps/documentation/embed/guide\">https://developers.google.com/maps/documentation/embed/guide</a>. La macro Gmap ne fonctionne qu'en combinaison avec la clé intégrée."
hidden_macros_in_toolbar_info: "Toutes les macros disponibles que l'utilisateur connecté peut utiliser sont listées via le bouton macro de la barre d'outils wiki. Les macros marquées ici ne sont pas proposées à la sélection. Ceci vous permet de limiter la portée de la liste."
info_dashboard_project_select: Laisser vide, si vous souhaitez utiliser ce tableau de bord pour tous les projets.
info_hidden_roles_html: "Les rôles cachés ne peuvent être utilisés qu'avec la visibilité utilisateur \"Membres de projets visibles\". Si l'utilisateur n'est pas dans un rôle visible par l'utilisateur actuel, ce rôle, y compris l'utilisateur, est masqué sur la page de synthèse du projet et dans les listes de requêtes."
info_live_search_result_restriction: "Les résultats de LiveSearch sont limités à %{value} résultats limités. Essaie de décrire ta recherche plus précisément."
label_account_login_bottom: "Texte pour la page de connexion"
Expand Down Expand Up @@ -195,3 +194,4 @@ fr:
label_help_doc: Documentation
label_activate_quickstart: "Activer quickstart"
label_quickstart: Quickstart
label_all_projects: All projects
2 changes: 1 addition & 1 deletion config/locales/it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ it:
global_wiki_sidebar_info: 'Enter a project wide available text message for your wiki sidebar, here. This sidebar text will be displayed at the wiki pages only. Use this space for Macros like "Last changed pages" for example. In case a project specific sidebar is used (wiki page), this will be preferably displayed in the sidebar instead.'
google_maps_embed_api_html: Se si desidera utilizzare la macro Gmap per visualizzare Google Maps, è necessario immettere qui la chiave API incorporata di Google Maps. Potete trovare maggiori informazioni sotto <a href="https://developers.google.com/maps/documentation/embed/guide">https://developers.google.com/maps/documentation/embed/guide</a>
hidden_macros_in_toolbar_info: "Tutte le macro disponibili che l'utente registrato può utilizzare sono elencate tramite il pulsante macro della barra degli strumenti del wiki. Le macro contrassegnate qui non vengono offerte per la selezione. In questo modo è possibile limitare la portata dell'elenco."
info_dashboard_project_select: "Lascialo vuoto, se vuoi usare questo cruscotto per tutti i progetti."
info_hidden_roles_html: "I ruoli nascosti possono essere utilizzati solo insieme alla visibilità dell'utente \"Membri di progetti visibili\". Se l'utente non è in un ruolo visibile all'utente corrente, questo ruolo, incluso l'utente, è nascosto nella pagina di panoramica del progetto e nelle liste di ricerca."
info_live_search_result_restriction: "I risultati di LiveSearch sono limitati a %{value} colpi. Prova a descrivere la tua ricerca in modo più dettagliato."
label_account_login_bottom: "Testo per la pagina di accesso"
Expand Down Expand Up @@ -195,3 +194,4 @@ it:
label_help_doc: Documentazione
label_activate_quickstart: Attivare quickstart
label_quickstart: Quickstart
label_all_projects: All projects
2 changes: 1 addition & 1 deletion config/locales/ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ ja:
global_wiki_sidebar_info: 'プロジェクト全体のWikiサイドバーで使用される文章を入力する。このサイドバー文章は、Wikiページのみに表示されます。例えば、「直近変更されたページ」等のマクロで使う事をお勧めします。もしプロジェクト特有のサイドバーが使用されている場合でも、こちらの文章がサイドバーで優先的に表示されます。'
google_maps_embed_api_html: In case you want to use the Gmap macro in order to display Goole maps please implement your Google Maps API key here. Afterwards you can use the macro and various paramters. More information on how to use the paramaters are provided at <a href="https://developers.google.com/maps/documentation/embed/guide" target="_blank">https://developers.google.com/maps/documentation/embed/guide</a>. The Gmap macro works only in combination with the embedded key here.
hidden_macros_in_toolbar_info: "ログインしているユーザーが使用できるすべての利用可能なマクロは、wikiツールバーのマクロボタンを使ってリストアップされています。ここでマークされたマクロは選択のために提供されていません。これにより、リストの範囲を制限することができます。"
info_dashboard_project_select: "すべてのプロジェクトでこのダッシュボードを使用する場合は、空白のままにしてください。"
info_hidden_roles_html: Hidden roles can only be used together with the user visibility "Members of visible projects". If the user is not in a role that is visible to the current user, this role including user is hidden on the project overview page and in query lists.
info_live_search_result_restriction: "LiveSearchの検索結果は %{value} に限定されます。がヒットしました。検索内容をもっと詳しく説明してみてください。"
label_account_login_bottom: "ログイン画面の文章"
Expand Down Expand Up @@ -195,3 +194,4 @@ ja:
label_help_doc: ドキュメンテーション
label_activate_quickstart: "アクティブ化 quickstart"
label_quickstart: Quickstart
label_all_projects: All projects
2 changes: 1 addition & 1 deletion config/locales/ko.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ ko:
global_wiki_sidebar_info: '위키 사이드 바에 사용할 수있는 프로젝트 전체 문자 메시지를 여기에 입력하십시오. 이 사이드 바 텍스트는 위키 페이지에만 표시됩니다. 예를 들어 "마지막으로 변경된 페이지"와 같은 매크로에이 공간을 사용하십시오. 프로젝트 특정 사이드 바가 사용되는 경우 (위키 페이지), 대신 사이드 바에 표시되는 것이 좋습니다.'
google_maps_embed_api_html: 'Goole지도를 표시하기 위해 Gmap 매크로를 사용하려는 경우 여기에 Google Maps API 키를 구현하십시오. 그 후 매크로 및 다양한 매개 변수를 사용할 수 있습니다. 매개 변수를 사용하는 방법에 대한 자세한 내용은 <a href="https://developers.google.com/maps/documentation/embed/guide" target="_blank">https://developers.google.com/maps/documentation/embed/guide</a>. Gmap 매크로는 여기에 포함 된 키와 조합해서 만 작동합니다.'
hidden_macros_in_toolbar_info: 로그인 한 사용자가 사용할 수있는 모든 매크로가 위키 도구 모음의 매크로 버튼을 통해 나열됩니다. 여기에 표시된 매크로는 선택할 수 없습니다. 이를 통해 목록의 범위를 제한 할 수 있습니다.
info_dashboard_project_select: 이 대시보드가 모든 프로젝트에서 보이기 원하면 이 항목을 비워두세요.
info_hidden_roles_html: Hidden roles can only be used together with the user visibility "Members of visible projects". 사용자가 현재 사용자에게 보이는 역할이 아닌 경우 사용자를 포함한이 역할은 프로젝트 개요 페이지와 쿼리 목록에서 숨겨집니다.
info_live_search_result_restriction: "LiveSearch results are limited to %{value} Matches. Try to describe your search in more detail."
label_account_login_bottom: "로그인 페이지의 텍스트"
Expand Down Expand Up @@ -195,3 +194,4 @@ ko:
label_help_doc: Documentation
label_activate_quickstart: "활성화 quickstart"
label_quickstart: Quickstart
label_all_projects: All projects
Loading

0 comments on commit 55312e4

Please sign in to comment.