Adding Marketer and Sales Admin Events Relationship with User on Open Event Server
In this blog, we will talk about how to add API for adding and displaying events in with a user acts as a Marketer and/or Sales Admin on Open Event Server. The focus is on Model Updation and Schema updation of User.
Model Updation
For the Marketer and Sales Admin events, we’ll update User model as follows
Now, let’s try to understand these relationships.
In this feature, we are providing user to act as a marketer and sales admin for a event.
- Both the relationships will return the events in which the user is acting as a Marketer and/or Sales Admin.
- There are two custom system roles in model CustomSysRole which are Marketer and Sales Admin. A user can act as these custom system roles with respect to an event.
- In this relationship, we will return those events from UserSystemRole model in which a user is acting as Marketer Custom System Role and Sales Admin Custom System Role.
- We make use of Event and join UserSystemRole and CustomSysRole where we use that user where UserSystemRole.user_id == User.id , CustomSysRole.id == UserSystemRole.role_id, CustomSysRole.name == “Sales Admin” and then we return events in which Event.id == UserSystemRole.event_id
- Similarly, for Marketer events we make use of Event and join UserSystemRole and CustomSysRole where we use that user where UserSystemRole.user_id == User.id , CustomSysRole.id == UserSystemRole.role_id, CustomSysRole.name == “Marketer” and then we return events in which Event.id == UserSystemRole.event_id
Schema Updation
For the Marketer and Sales Admin events, we’ll update UserSchema as follows
Now, let’s try to understand this Schema.
In this feature, we are providing user to act as a marketer and sales admin for a event.
- For displaying marketer_events relation self_view is displayed by API v1.user_marketer_events and collection of these events is displayed by API v1.event_list
- These APIs will return the Events as schema=”EventSchema”. Here, many=True tells us that this is One to many relationship with Events model.
So, we saw how an user can act as a marketer and/or sales admin for many events.
Resources
- Documentation | Marshmallow: https://marshmallow-jsonapi.readthedocs.io/en/latest/
- Fossasia Blog | Permissions for Custom roles on Open Event Server: https://blog.fossasia.org/adding-panel-permissions-api-in-open-event-server/
- Documentation | Roles in Open Event Server: https://github.com/fossasia/open-event-server/blob/development/docs/general/roles.md
You must be logged in to post a comment.