I am working for a medical project, where i hold so many modules like..
Regisration
Login
There are 2 types of users in the system:
Patient
Profile
Patient history
Appointments (also in doctor)
Prescriptions
Lab Reports
Doctor
Schedules
Appointments (also in patient)
Create Hospital
Can i make every user as a module in zend framework 2, or creating a single module and make every other functionality(appointments, schedules) as a controller.
Can anyone guide me..
As pointed out by AlexP in the comments this is not true at all.
First off no you shouldn't create modules for each of these users. These pretty much just types of Users using your system. I.e User Roles.
Now there various ways and modules that could achieve restrictions regarding those users I personally like BjyAuthorize. This uses zendframeworks ACL implementation with further improvements to the usability etc.
Within your BjyAuthorize configuration you just configure what each Role can see/access/edit etc. and you should be good to go.
Related
I am trying to build a MVC Core app for an organisation. There is some vague requirements which I am not able to comprehend. I hope the community helps me out here.
There will be two types of users. One will be the admin and the other will be the normal users. The admin can access the admin module and the rest of the modules while each of these normal users will have access to different modules (except the admin one) and the sub-menus inside those modules. Let me explain that.
Let us suppose we have two modules : Disaster Recovery and Asset Tracking. The admin will be able to access each of these modules. But some of the normal users may or may not be able to access each of these two modules. Some of the users may have the authorization to access both modules while some of them will have access to only one.
Now here comes the tricky part. Inside each modules are sub-menus. For example if we have a module named Asset Tracking, the sub-menus inside this module can be ASST0001, ASST0002 and so on. These sub-menus are my MVC views. Again if a user has access to a module does not mean he/she will have access to the whole sub-menus of that said module. This app will be scalable and the no of users may increase as the time progresses.
How do I approach this problem? What would be the most efficient way and scalable way to approach this problem ?
I am sorry if I may seem naive but this is my first real job at designing something like this. I search the internet and most of them were talking about Roles, Users and Permissions which honestly just breezed over my head. Please guide me.
You need to use custom requirements for this Creating a custom requirement is a blog post for this.
You can even inject Dbcontext or repositories in requirement handle
I have seen regular debates about the way to manage the different class of users.
Usually, it seems that developers prefer a role based approach (e.g. user, admin,...) with gems like Cancancan
But I'm wondering if it's applicable for an appointment booking app (appointment for doctors, teachers,... or even bookings). Indeed in this case, the 2 types of users have access to totally different pages. In its documentation about associations, Ruby on Rails guide takes the example of a medical appointment booking app with 1 table for doctors and 1 table for patients.
For this kind of app, I'm a little bit lost regarding the most efficient solution!
Thanks!
You can use a tool like Cancanan to break out the different roles and abilities, then restrict access to certain parts of the system based on those rules.
Additionally you can display only the relevant navigation or pages when the user's accessing the system so they might not even be aware of what they're not seeing.
I'm still learning Rails, but faced with this project: Web solution should consist of three parts - the website, section for partners and admin panel. Section for partners and admin panel should be available as subdirectories (customer's requirement) like this:
somesite.com
somesite.com/partners/
somesite.com/admin/
I decided to make three separate applications with common models and business logic and deploy them in mentioned way using Passenger and Apache.
In the database should be two models: Admin (for administrators only) and User (quite fat model, common for users and partners, differs by is_partner field). Because those models are common to all three sites, I decided to put them in the Rails Engine, and then use appropriate model for each application. But now I have the issue of choosing the suitable authentication module.
Could you advice one? Should I try to use some already existing solution or I better have to implement my own authentication? Or may be my entire approach to this project is wrong from beginning?
Thank you.
I would use one User model, since you won't need to duplicate any logic, and use three roles: user, partner, and admin, unless admins are drastically different from other users. For authentication, I would suggest Devise, which is the go-to authentication system for Rails. For authorization, I would suggest CanCan.
If you're looking for a pre-made admin interface, try RailsAdmin or ActiveAdmin. RailsAdmin is simple to use and easily configurable, but not too customizable, while ActiveAdmin is a little more difficult to use but more customizable. Both of them are integrated with devise.
I'm working on an app with Project, User, and Group models. A Project has many groups, a User belongs to many groups through a Membership model. I have two choices:
When a Project is created, a default group is created. Any person participating in this project is automatically added to it.
Make Memberships polymorphic so that users can be a member of a project, and a group in the project.
Both approaches have wider implications: Other models will come into play, such as: File, Post, and Task.
If I go for option 2, those models will also have to be polymorphic. But it would simplify things a bit.
If I go for option two, I forgo polymorphism, but things get a bit complicated. For example, finding the users projects means I have to query for the user's groups, then projects associated with those groups, and then make sure the projects are unique.
Has anyone faced a similar situation, any advice or additional pros and cons for either approach?
I really would rather ditch groups altogether, but it's a requirement for permissions, to separate content based on group.
I think best option would be creating a default group, because:
Then you can go with a clear structure:
projects - has many groups
groups -> has many users etc,
you will have the flexibility of managing groups easily
your core structure is simple, hence years down the line, easy to expand
you are easing the work flow of user by automating a one step. I personally believe if you could let a user to up and running quickly, they will find your system user friendly
Rather than the typical one store app, where I (as a user) go and add products that one seller (the owner of the Spree app) is selling, what I want to do is to create an ecommerce site that has multiple vendors.
So you could see an overview of all vendors, and then you can buy multiple products from multiple vendors.
Does Spree allow me to customize it to that extent?
If so, are there any docs for that?
Thanks.
One approach (the one I used), is to add a 'vendor' Property to each item. Note - this approach assumes that each item is only sold by a single vendor. If you actually have a marketplace with various vendors competing to sell the same item, you'll need to do a similar thing by adding a 'vendor' OptionType, that is defined for each product Variant.
Each vendor (new model) is assigned a code that can be used when setting up your items (as either a property value, or multiple variant option values). When an order is placed, you can use a new OrderFulfillment model to track the various shipments that the various vendors will use to fulfill that order (one OrderFulfillment record per vendor in the order).
That's basically all the model changes you'll need. In the controller area, you'll need to modify the 'shopping cart' event machine sequence to handle the different vendor's shipping methods. And in the case of multiple vendors, you'll also need to present the user with a choice of vendor (think amazon marketplace).
How you handle your payments to various vendors was not part of my project, but shouldn't be too complex to add if needed.
Regarding links: You should be familiar with the basic Spree concepts which are discussed in the guide in general, and more specifically here. You will also need to make some internal modifications (new associations, modified controller behavior) which you can read about here.
I think you have a few options available for that.
Essentially, you want an e commerce app where users can sign up and list their own products, and then have a user profile page where someone can look and see just that user's products, right? Some people call this multi-tenancy, and if you do a google search you will soon find this spree extension: multi-tenant
I am looking to do the same thing as you, and I'm a bit wary of multi tenant because I would have to roll back to Spree 2-2 stable (I'm currently on 2-3).
The previous answer here suggests that you should create a new model called Vendor. I would say why not just update your already existing user model to become a vendor?
What I'm suggesting is simply creating an association between the User model and the Spree::Products model. This way you can scope products to individual users and create profile pages without the complexity of adding new, foreign models and/or different admins for each user. All of the spree methods are already attached to your User class, so I would think a simple belongs_to/has_many association would work. Haven't tested this at all, but that's what my thinking is.