# Path: oxidizr/apps/projects/models.py
# class Project(models.Model):
#     """
#     This model allows us to enable multiple tenants register on and use Oxidizr.
#     Like in other hosted Software as a Service, we store almost all other data per tenant.
#     """
#     name = models.CharField(max_length=100)
#     owner = models.ForeignKey(settings.AUTH_USER_MODEL)
# 
#     def __str__(self):
#         return '%s' % self.name
# 
#     def __unicode__(self):
#         return u'%s' % self.name


from django.views.generic import ListView
from django.utils.translation import ugettext_lazy as _
from django.core.urlresolvers import reverse_lazy
from django.contrib import messages
from django.shortcuts import redirect
from braces.views import LoginRequiredMixin
from .models import Project




class ProjectIndexView(LoginRequiredMixin, ListView):
    model = Project
    template_name = 'projects/index.html'
    context_object_name = 'projects'

    def get_queryset(self):
        return Project.objects.filter(owner=self.request.user)

    def get(self, request, *args, **kwargs):
        if self.kwargs.get('id', None):
            try:

# Path: oxidizr/apps/projects/models.py
# class Project(models.Model):
#     """
#     This model allows us to enable multiple tenants register on and use Oxidizr.
#     Like in other hosted Software as a Service, we store almost all other data per tenant.
#     """
#     name = models.CharField(max_length=100)
#     owner = models.ForeignKey(settings.AUTH_USER_MODEL)
# 
#     def __str__(self):
#         return '%s' % self.name
# 
#     def __unicode__(self):
#         return u'%s' % self.name


# Path: oxidizr/apps/projects/views.py
from django.views.generic import ListView
from django.utils.translation import ugettext_lazy as _
from django.core.urlresolvers import reverse_lazy
from django.contrib import messages
from django.shortcuts import redirect
from braces.views import LoginRequiredMixin
from .models import Project





class ProjectIndexView(LoginRequiredMixin, ListView):
    model = Project
    template_name = 'projects/index.html'
    context_object_name = 'projects'

    def get_queryset(self):
        return Project.objects.filter(owner=self.request.user)

    def get(self, request, *args, **kwargs):
        if self.kwargs.get('id', None):
            try:

                Project.objects.get(id=self.kwargs.get('id', None), owner=request.user)