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

User auth of services/projects #210

Closed
sundy-li opened this issue Dec 10, 2019 · 2 comments
Closed

User auth of services/projects #210

sundy-li opened this issue Dec 10, 2019 · 2 comments

Comments

@sundy-li
Copy link

sundy-li commented Dec 10, 2019

Admin could create lots of users, yet each user must only view or update there own services/projects.

@kfdm
Copy link
Collaborator

kfdm commented Dec 10, 2019

Eventually I would like to support something like this, but it will require a bit of refactoring first

@sundy-li
Copy link
Author

We have a fork version of promgen in our comany, we just modify the ServiceListView to did that.

class ServiceList(LoginRequiredMixin, ListView):
    template_name = 'promgen/service_list.html'

    def get_queryset(self):
        paginate_by = 20
        services = models.Service.objects
        if not self.request.user.is_superuser:
            services = models.Service.objects.filter(owner = self.request.user)
        return services.prefetch_related(
            "rule_set",
            "rule_set__parent",
            "project_set",
            "project_set__owner",
            "project_set__shard",
            "project_set__notifiers",
            "project_set__notifiers__owner",
            "project_set__notifiers__filter_set",
            "project_set__farm",
            "project_set__exporter_set",
            "owner",
            "notifiers",
            "notifiers__owner",
            "notifiers__filter_set",
        )

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

No branches or pull requests

2 participants