Display menu according to role sonataAdminBundle - sonata-admin

How can I display the sidebare menus according to role under sonataAdminBundle?
That's what I did at:
config.yml
sonata.admin.group.livreur:
label: Livreur
label_catalogue: SonataAdminBundle
icon: ''
items:
- cadicom.admin.livreur
security.yml
ROLE_ADMIN_LIVREUR:
- ROLE_ADMIN
- ROLE_SONATA_ADMIN
- ROLE_ALLOWED_TO_SWITCH
- ROLE_SONATA_MEDIA_ADMIN_MEDIA_ADMIN
- ROLE_APP_ADMIN_PROMOTIIN_ADMIN
- ROLE_SONATA_MEDIA_ADMIN_GALLERY_HAS_MEDIA_ADMIN
- ROLE_CADICOM_ADMIN_LIVREUR_ADMIN
services.yml
cadicom.admin.livreur:
class: cadicomBundle\Admin\LivreurAdmin
arguments: [~, cadicomBundle\Entity\Livreur, SonataAdminBundle:CRUD]
tags:
- { name: sonata.admin, manager_type: orm, group: admin, label: Livreur }
My pb is that the delivery section does not appear for the admin that's assigned the role ROLE_ADMIN_LIVREUR

Related

Best way to conditionally override an item value in an Ansible loop

I'm attempting to adapt an existing play that was built for automating account creation and deletion in a small environment without centralized authentication. Since then the scope has expanded and we've added bastion servers where it's not appropriate for all accounts to be created.
Because user IDs are hard coded (not desirable - I know) I'd like to avoid having a separate play for the bastions as that means keeping track of UIDs in two places. My workaround was to add an onbastion boolean to each row, then use that in create-account.yml to flip the state to absent if applicable. I originally tried changing the value of item.state directly but ran into syntax errors that I couldn't figure out. So I added a set_fact task to set the value of a new variable conditionally, but the playbook now fails with a message that "The task includes an option with an undefined variable. The error was: 'desired_item_state' is undefined".
What am I missing, and is there a better way to tackle this? Thanks in advance!
Relevant Snippets
project/roles/create-accounts/default/main.yml
users:
- { name: "user_1", id: 15001, state: "present", groups: ["project"], onbastion: true }
- { name: "user_2", id: 15002, state: "present", groups: ["project"], onbastion: true }
- { name: "fired_user_3", id: 15003, state: "absent", groups: [], onbastion: false}
- { name: "retired_user_4", id: 15004, state: "absent", groups: [], onbastion: false}
- { name: "osr1", id: 15009, state: "present", groups: ["project"], onbastion: false }
- { name: "osr2", id: 15010, state: "present", groups: ["project"], onbastion: false }
- { name: "osr3", id: 15011, state: "present", groups: ["project"], onbastion: false }
- { name: "project_svc", id: 15018, state: "present", groups: ["project"], onbastion: false }
- { name: "jenkins", id: 15019, state: "present", groups: ["project"], onbastion: false }
project/roles/create-accounts/tasks/main.yml
- name: Set up user accounts
ansible.builtin.include_tasks: create-account.yml
loop: "{{ users }}"
project/roles/create-accounts/tasks/create-account.yml
---
- name: Update item state if on bastion
set_fact:
desired_item_state: "{{ 'absent' if ('bastion' in group_names and item.onbastion == false) else item.state }}"
- name: Create/update {{ item.name }} user ID
become: true
ansible.builtin.user:
name: "{{ item.name }}"
state: "{{ desired_item_state }}"
uid: "{{ item.id }}"
groups: "{{ item.groups }}"
append: yes
update_password: on_create
password: "!"
- name: Create/update {{ item.name }} group ID
become: true
ansible.builtin.group:
name: "{{ item.name }}"
state: "{{ desired_item_state }}"
gid: "{{ item.id }}"
- name: Update ownership of /home/{{ item.name }}
become: true
ansible.builtin.file:
path: /home/{{ item.name }}
state: directory
recurse: yes
owner: "{{ item.name }}"
group: "{{ item.name }}"
when: desired_item_state == 'present'
Output
TASK [create-accounts : Create/update osr1 user ID] ***********************
fatal: [project-subsystem-bastion2]: FAILED! =>
msg: |-
The task includes an option with an undefined variable. The error was: 'desired_item_state' is undefined
The error appears to be in '/project/ansible-e86f3754/plays/roles/create-accounts/tasks/create-account.yml': line 13, column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- name: Create/update {{ item.name }} user ID
^ here
We could be wrong, but this one looks like it might be an issue with
missing quotes. Always quote template expression brackets when they
start a value. For instance:
with_items:
- {{ foo }}
Should be written as:
with_items:
- "{{ foo }}"
See comments. flowerysong was unable to reproduce my issue, and the only thing I'd left out were tags on the tasks. Lesson learned: sanitize code before posting but don't leave anything out.

Dynamic react routes from JSON object

I am new to React and trying to learn the react-router. I can loop through the JSON object using the map method. But I am struggling to find a way to display the component based on each iteration. Like if the name is displayed, I want to display another array of objects in that particular iteration. I tried looking at the switch but I can't understand. Please help!!
render() {
return this.props.topic.map(t => (
<ul>
<li>
<Link to={`${t.name}`}>{t.name}</Link>
</li>
</ul>
));
<Switch>
<Route path="/:id" children={<Child />} />
</Switch>
}
This is the JSON object
topics = [
{
name: 'React Router',
id: 'react-router',
description: 'Declarative, component based routing for React',
resources: [
{
name: 'URL Parameters',
id: 'url-parameters',
description: "URL parameters are parameters whose values are set
dynamically in a page's URL. This allows a route to render the same
component while passing that component the dynamic portion of the
URL so it can change based off of it.",
url: 'https://tylermcginnis.com/react-router-url-parameters/'
},
{
name: 'Programmatically navigate',
id: 'programmatically-navigate',
description: "When building an app with React Router, eventually
you'll run into the question of navigating programmatically. The
goal of this post is to break down the correct approaches to
programmatically navigating with React Router.",
url: 'https://tylermcginnis.com/react-router-programmatically-
navigate/'
}
]
},
{
name: 'React.js',
id: 'reactjs',
description: 'A JavaScript library for building user interfaces',
resources: [
{
name: 'React Lifecycle Events',
id: 'react-lifecycle',
description: "React Lifecycle events allow you to tie into specific
phases of a component's life cycle",
url: 'https://tylermcginnis.com/an-introduction-to-life-cycle-
events-in-react-js/'
},
{
name: 'React AHA Moments',
id: 'react-aha',
description: "A collection of 'Aha' moments while learning React.",
url: 'https://tylermcginnis.com/react-aha-moments/'
}
]
},
{
name: 'Functional Programming',
id: 'functional-programming',
description: 'In computer science, functional programming is a
programming paradigm—a style of building the structure and elements of
computer programs—that treats computation as the evaluation of
mathematical functions and avoids changing-state and mutable data.',
resources: [
{
name: 'Imperative vs Declarative programming',
id: 'imperative-declarative',
description: 'A guide to understanding the difference between
Imperative and Declarative programming.',
url: 'https://tylermcginnis.com/imperative-vs-declarative-
programming/'
},
{
name: 'Building User Interfaces with Pure Functions and Function
Composition',
id: 'fn-composition',
description: 'A guide to building UI with pure functions and
function composition in React',
url: 'https://tylermcginnis.com/building-user-interfaces-with-pure-
functions-and-function-composition-in-react-js/'
}
]
}
]

I use hugo build static page. But don't have content

enter image description here
Deploy don't have error.
But there's nothing on my page.
https://sillyhatxu.github.io/
Set the parameters
draft: false
For Example
---
title: "Golang bit operation"
subtitle: "Golang 位运算"
date: 2019-05-27T23:13:11+08:00
author: "one_zheng"
tags: ["golang","algorithm"]
categories: ["golang"]
from: "https://medium.com/learning-the-go-programming-language/bit-hacking-with-go-e0acee258827"
draft: false
---

Meteor Angular collections relations

I'm using urigo:angular package. In my project I have two collections: posts and users. Is it possible to publish from server an object, which looks like this:
[{createdAt: 20-12-2015,
text: 'something',
user: { name: 'some name'}
},
{createdAt: 22-12-2015,
text: 'something2',
user: { name: 'some other name'}
}]
I mean insert user object to every post.
Update:
I have two collectionsL posts and users. Every post has user id. When I do something like this with publishComposite: https://github.com/Nitrooos/Forum-Steganum/blob/posts/server/posts.methods.coffee then I have on the client side (https://github.com/Nitrooos/Forum-Steganum/blob/posts/client/posts/posts.controller.coffee) only an array with posts, without the user in it.
I have this:
[{createdAt: 20-12-2015,
text: 'something',
userId: 123
},
{createdAt: 22-12-2015,
text: 'something2',
userId: 123
}]
So, when I'll want display a username, I'll have to do a request to every post about user?

sencha touch routing extraparams kitchensink

I am trying to extend the routing in the Sencha Touch Kitchensink app as follows:
My data (in List store) are as follows:
{ category: 'fruit', str: 'tomato'},
{ category: 'fruit', str: 'green bean'},
{ category: 'vegetable', str: 'celery'},
{ category: 'vegetable', str: 'sprouts'},
{ category: 'notAVegetable', str: 'ketchup'},
{ category: 'notAVegetable', str: 'prune'}
I would like to show only those data selected by a particular category, such as "fruit"
In the Main.js controller, I am trying to do this by grabbing another parameter from the "List" node in the Demos TreeStore
routes: {
'demo/:id/:category': 'showViewById',
'menu/:id': 'showMenuById'
},
Where the showViewById action adds the extra parameter for use later
showViewById: function (id, category) {
var nav = this.getNav(),
view = nav.getStore().getNodeById(id);
console.log('view ' + id);
this.showView(view);
this.setCurrentDemo(view);
this.hideSheets();
// do stuff with category
},
I am trying to add and access 'category' as an extraParameter in my Demos.js store in the "List" tree node as follows:
{
text: 'List',
leaf: true,
id: 'list',
extraParams: {
category: 'fruit'
}
},
A few questions: Can I use an extraParameter to add this attribute to the Store? If so, how can I access it to use for my routing? I thought it would be available as metadata for my Demos store, but have not been able to access it.
Any alternatives short of creating multiple stores (one for "fruit", "vegetable", "notAVegetable," etc.) with filters on them to achieve the same thing?
TIA!

Resources