Minor refactor.
parent
a16847ce58
commit
d2ada59b6f
|
@ -13,7 +13,7 @@ from rest_framework.permissions import IsAuthenticated
|
||||||
from rest_framework import status
|
from rest_framework import status
|
||||||
from rest_framework import generics
|
from rest_framework import generics
|
||||||
|
|
||||||
from haystack.query import SearchQuerySet
|
from haystack import query, inputs
|
||||||
|
|
||||||
from greenmine.base.serializers import LoginSerializer, UserLogged, UserSerializer, RoleSerializer
|
from greenmine.base.serializers import LoginSerializer, UserLogged, UserSerializer, RoleSerializer
|
||||||
from greenmine.base.serializers import SearchSerializer
|
from greenmine.base.serializers import SearchSerializer
|
||||||
|
@ -149,11 +149,15 @@ class Logout(APIView):
|
||||||
class Search(APIView):
|
class Search(APIView):
|
||||||
def get(self, request, format=None):
|
def get(self, request, format=None):
|
||||||
text = request.QUERY_PARAMS.get('text', None)
|
text = request.QUERY_PARAMS.get('text', None)
|
||||||
|
project = request.QUERY_PARAMS.get('project', None)
|
||||||
|
|
||||||
if text:
|
if text and project:
|
||||||
#TODO: permission check
|
#TODO: permission check
|
||||||
results = SearchQuerySet().filter(content=text)[:settings.MAX_SEARCH_RESULTS]
|
queryset = query.SearchQuerySet()
|
||||||
return_data = SearchSerializer(results)
|
queryset = queryset.filter(text=inputs.AutoQuery(text))
|
||||||
|
queryset = queryset.filter(project_id=project)
|
||||||
|
|
||||||
|
return_data = SearchSerializer(queryset)
|
||||||
return Response(return_data.data)
|
return Response(return_data.data)
|
||||||
|
|
||||||
return Response({"detail": "Parameter text can't be empty"}, status.HTTP_400_BAD_REQUEST)
|
return Response({"detail": "Parameter text can't be empty"}, status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
|
@ -100,22 +100,22 @@
|
||||||
"document"
|
"document"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"can_change_owned_documents",
|
"change_owned_documents",
|
||||||
"documents",
|
"documents",
|
||||||
"document"
|
"document"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"can_download_from_my_projects",
|
"download_from_my_projects",
|
||||||
"documents",
|
"documents",
|
||||||
"document"
|
"document"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"can_download_from_other_projects",
|
"download_from_other_projects",
|
||||||
"documents",
|
"documents",
|
||||||
"document"
|
"document"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"can_view_documents",
|
"view_documents",
|
||||||
"documents",
|
"documents",
|
||||||
"document"
|
"document"
|
||||||
],
|
],
|
||||||
|
@ -135,37 +135,37 @@
|
||||||
"question"
|
"question"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"can_assign_question_to_myself",
|
"assign_question_to_myself",
|
||||||
"questions",
|
"questions",
|
||||||
"question"
|
"question"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"can_assign_question_to_other",
|
"assign_question_to_other",
|
||||||
"questions",
|
"questions",
|
||||||
"question"
|
"question"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"can_change_assigned_question",
|
"change_assigned_question",
|
||||||
"questions",
|
"questions",
|
||||||
"question"
|
"question"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"can_change_owned_question",
|
"change_owned_question",
|
||||||
"questions",
|
"questions",
|
||||||
"question"
|
"question"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"can_change_question_state",
|
"change_question_state",
|
||||||
"questions",
|
"questions",
|
||||||
"question"
|
"question"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"can_reply_question",
|
"reply_question",
|
||||||
"questions",
|
"questions",
|
||||||
"question"
|
"question"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"can_view_question",
|
"view_question",
|
||||||
"questions",
|
"questions",
|
||||||
"question"
|
"question"
|
||||||
],
|
],
|
||||||
|
@ -215,37 +215,37 @@
|
||||||
"issue"
|
"issue"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"can_assign_issue_to_myself",
|
"assign_issue_to_myself",
|
||||||
"scrum",
|
"scrum",
|
||||||
"issue"
|
"issue"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"can_assign_issue_to_other",
|
"assign_issue_to_other",
|
||||||
"scrum",
|
"scrum",
|
||||||
"issue"
|
"issue"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"can_change_assigned_issue",
|
"change_assigned_issue",
|
||||||
"scrum",
|
"scrum",
|
||||||
"issue"
|
"issue"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"can_change_issue_state",
|
"change_issue_state",
|
||||||
"scrum",
|
"scrum",
|
||||||
"issue"
|
"issue"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"can_change_owned_issue",
|
"change_owned_issue",
|
||||||
"scrum",
|
"scrum",
|
||||||
"issue"
|
"issue"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"can_comment_issue",
|
"comment_issue",
|
||||||
"scrum",
|
"scrum",
|
||||||
"issue"
|
"issue"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"can_view_issue",
|
"view_issue",
|
||||||
"scrum",
|
"scrum",
|
||||||
"issue"
|
"issue"
|
||||||
],
|
],
|
||||||
|
@ -310,7 +310,7 @@
|
||||||
"milestone"
|
"milestone"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"can_view_milestone",
|
"view_milestone",
|
||||||
"scrum",
|
"scrum",
|
||||||
"milestone"
|
"milestone"
|
||||||
],
|
],
|
||||||
|
@ -360,17 +360,17 @@
|
||||||
"project"
|
"project"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"can_list_projects",
|
"list_projects",
|
||||||
"scrum",
|
"scrum",
|
||||||
"project"
|
"project"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"can_manage_users",
|
"manage_users",
|
||||||
"scrum",
|
"scrum",
|
||||||
"project"
|
"project"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"can_view_project",
|
"view_project",
|
||||||
"scrum",
|
"scrum",
|
||||||
"project"
|
"project"
|
||||||
],
|
],
|
||||||
|
@ -405,42 +405,42 @@
|
||||||
"task"
|
"task"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"can_add_task_to_us",
|
"add_task_to_us",
|
||||||
"scrum",
|
"scrum",
|
||||||
"task"
|
"task"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"can_assign_task_to_myself",
|
"assign_task_to_myself",
|
||||||
"scrum",
|
"scrum",
|
||||||
"task"
|
"task"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"can_assign_task_to_other",
|
"assign_task_to_other",
|
||||||
"scrum",
|
"scrum",
|
||||||
"task"
|
"task"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"can_change_assigned_task",
|
"change_assigned_task",
|
||||||
"scrum",
|
"scrum",
|
||||||
"task"
|
"task"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"can_change_owned_task",
|
"change_owned_task",
|
||||||
"scrum",
|
"scrum",
|
||||||
"task"
|
"task"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"can_change_task_state",
|
"change_task_state",
|
||||||
"scrum",
|
"scrum",
|
||||||
"task"
|
"task"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"can_comment_task",
|
"comment_task",
|
||||||
"scrum",
|
"scrum",
|
||||||
"task"
|
"task"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"can_view_task",
|
"view_task",
|
||||||
"scrum",
|
"scrum",
|
||||||
"task"
|
"task"
|
||||||
],
|
],
|
||||||
|
@ -475,27 +475,27 @@
|
||||||
"userstory"
|
"userstory"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"can_add_userstory_to_milestones",
|
"add_userstory_to_milestones",
|
||||||
"scrum",
|
"scrum",
|
||||||
"userstory"
|
"userstory"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"can_change_owned_userstory",
|
"change_owned_userstory",
|
||||||
"scrum",
|
"scrum",
|
||||||
"userstory"
|
"userstory"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"can_comment_userstory",
|
"comment_userstory",
|
||||||
"scrum",
|
"scrum",
|
||||||
"userstory"
|
"userstory"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"can_delete_userstory",
|
"delete_userstory",
|
||||||
"scrum",
|
"scrum",
|
||||||
"userstory"
|
"userstory"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"can_view_userstory",
|
"view_userstory",
|
||||||
"scrum",
|
"scrum",
|
||||||
"userstory"
|
"userstory"
|
||||||
],
|
],
|
||||||
|
@ -560,12 +560,12 @@
|
||||||
"wikipage"
|
"wikipage"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"can_change_owned_wikipage",
|
"change_owned_wikipage",
|
||||||
"wiki",
|
"wiki",
|
||||||
"wikipage"
|
"wikipage"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"can_view_wikipage",
|
"view_wikipage",
|
||||||
"wiki",
|
"wiki",
|
||||||
"wikipage"
|
"wikipage"
|
||||||
],
|
],
|
||||||
|
|
|
@ -35,10 +35,10 @@ class Document(models.Model):
|
||||||
verbose_name_plural = u'document'
|
verbose_name_plural = u'document'
|
||||||
ordering = ['project', 'title', 'id']
|
ordering = ['project', 'title', 'id']
|
||||||
permissions = (
|
permissions = (
|
||||||
('can_download_from_my_projects', 'Can download the documents from my projects'),
|
('download_from_my_projects', 'Can download the documents from my projects'),
|
||||||
('can_download_from_other_projects', 'Can download the documents from other projects'),
|
('download_from_other_projects', 'Can download the documents from other projects'),
|
||||||
('can_change_owned_documents', 'Can modify owned documents'),
|
('change_owned_documents', 'Can modify owned documents'),
|
||||||
('can_view_documents', 'Can modify owned documents'),
|
('view_documents', 'Can modify owned documents'),
|
||||||
)
|
)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
|
|
|
@ -80,13 +80,13 @@ class Question(models.Model):
|
||||||
ordering = ['project', 'subject', 'id']
|
ordering = ['project', 'subject', 'id']
|
||||||
#TODO: permissions
|
#TODO: permissions
|
||||||
permissions = (
|
permissions = (
|
||||||
('can_reply_question', 'Can reply questions'),
|
('reply_question', 'Can reply questions'),
|
||||||
('can_change_owned_question', 'Can modify owned questions'),
|
('change_owned_question', 'Can modify owned questions'),
|
||||||
('can_change_assigned_question', 'Can modify assigned questions'),
|
('change_assigned_question', 'Can modify assigned questions'),
|
||||||
('can_assign_question_to_other', 'Can assign questions to others'),
|
('assign_question_to_other', 'Can assign questions to others'),
|
||||||
('can_assign_question_to_myself', 'Can assign questions to myself'),
|
('assign_question_to_myself', 'Can assign questions to myself'),
|
||||||
('can_change_question_state', 'Can change the question state'),
|
('change_question_state', 'Can change the question state'),
|
||||||
('can_view_question', 'Can view the question'),
|
('view_question', 'Can view the question'),
|
||||||
)
|
)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
|
|
|
@ -59,9 +59,10 @@ class ProjectList(NotificationSenderMixin, generics.ListCreateAPIView):
|
||||||
destroy_notification_template = "destroy_project_notification"
|
destroy_notification_template = "destroy_project_notification"
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return self.model.objects.filter(
|
qs = self.model.objects.filter(
|
||||||
Q(owner=self.request.user) | Q(members=self.request.user)
|
Q(owner=self.request.user) | Q(members=self.request.user)
|
||||||
)
|
)
|
||||||
|
return qs.distinct()
|
||||||
|
|
||||||
def pre_save(self, obj):
|
def pre_save(self, obj):
|
||||||
obj.owner = self.request.user
|
obj.owner = self.request.user
|
||||||
|
@ -86,7 +87,8 @@ class MilestoneList(NotificationSenderMixin, generics.ListCreateAPIView):
|
||||||
destroy_notification_template = "destroy_milestone_notification"
|
destroy_notification_template = "destroy_milestone_notification"
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return self.model.objects.filter(project__members=self.request.user)
|
qs = self.model.objects.filter(project__members=self.request.user)
|
||||||
|
return qs.distinct()
|
||||||
|
|
||||||
def pre_save(self, obj):
|
def pre_save(self, obj):
|
||||||
obj.owner = self.request.user
|
obj.owner = self.request.user
|
||||||
|
@ -111,7 +113,8 @@ class UserStoryList(NotificationSenderMixin, generics.ListCreateAPIView):
|
||||||
destroy_notification_template = "destroy_user_story_notification"
|
destroy_notification_template = "destroy_user_story_notification"
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return self.model.objects.filter(project__members=self.request.user)
|
qs = self.model.objects.filter(project__members=self.request.user)
|
||||||
|
return qs.distinct()
|
||||||
|
|
||||||
def pre_save(self, obj):
|
def pre_save(self, obj):
|
||||||
obj.owner = self.request.user
|
obj.owner = self.request.user
|
||||||
|
@ -140,10 +143,12 @@ class IssuesAttachmentList(generics.ListCreateAPIView):
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
ct = ContentType.objects.get_for_model(Issue)
|
ct = ContentType.objects.get_for_model(Issue)
|
||||||
return super(IssuesAttachmentList, self).get_queryset()\
|
qs = super(IssuesAttachmentList, self).get_queryset()\
|
||||||
.filter(project__members=self.request.user)\
|
.filter(project__members=self.request.user)\
|
||||||
.filter(content_type=ct)
|
.filter(content_type=ct)
|
||||||
|
|
||||||
|
return qs.distinct()
|
||||||
|
|
||||||
def pre_save(self, obj):
|
def pre_save(self, obj):
|
||||||
obj.content_type = ContentType.objects.get_for_model(Issue)
|
obj.content_type = ContentType.objects.get_for_model(Issue)
|
||||||
obj.owner = self.request.user
|
obj.owner = self.request.user
|
||||||
|
@ -163,10 +168,12 @@ class TasksAttachmentList(generics.ListCreateAPIView):
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
ct = ContentType.objects.get_for_model(Task)
|
ct = ContentType.objects.get_for_model(Task)
|
||||||
return super(TasksAttachmentList, self).get_queryset()\
|
qs = super(TasksAttachmentList, self).get_queryset()\
|
||||||
.filter(project__members=self.request.user)\
|
.filter(project__members=self.request.user)\
|
||||||
.filter(content_type=ct)
|
.filter(content_type=ct)
|
||||||
|
|
||||||
|
return qs.distinct()
|
||||||
|
|
||||||
def pre_save(self, obj):
|
def pre_save(self, obj):
|
||||||
obj.content_type = ContentType.objects.get_for_model(Task)
|
obj.content_type = ContentType.objects.get_for_model(Task)
|
||||||
obj.owner = self.request.user
|
obj.owner = self.request.user
|
||||||
|
@ -188,7 +195,8 @@ class TaskList(NotificationSenderMixin, generics.ListCreateAPIView):
|
||||||
destroy_notification_template = "destroy_task_notification"
|
destroy_notification_template = "destroy_task_notification"
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return self.model.objects.filter(project__members=self.request.user)
|
qs = self.model.objects.filter(project__members=self.request.user)
|
||||||
|
return qs.distinct()
|
||||||
|
|
||||||
def pre_save(self, obj):
|
def pre_save(self, obj):
|
||||||
obj.owner = self.request.user
|
obj.owner = self.request.user
|
||||||
|
@ -224,7 +232,8 @@ class IssueList(NotificationSenderMixin, generics.ListCreateAPIView):
|
||||||
obj.owner = self.request.user
|
obj.owner = self.request.user
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return self.model.objects.filter(project__members=self.request.user)
|
qs = self.model.objects.filter(project__members=self.request.user)
|
||||||
|
return qs.distinct()
|
||||||
|
|
||||||
|
|
||||||
class IssueDetail(NotificationSenderMixin, generics.RetrieveUpdateDestroyAPIView):
|
class IssueDetail(NotificationSenderMixin, generics.RetrieveUpdateDestroyAPIView):
|
||||||
|
@ -250,7 +259,8 @@ class SeverityList(generics.ListCreateAPIView):
|
||||||
permission_classes = (IsAuthenticated,)
|
permission_classes = (IsAuthenticated,)
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return self.model.objects.filter(project__members=self.request.user)
|
qs = self.model.objects.filter(project__members=self.request.user)
|
||||||
|
return qs.distinct()
|
||||||
|
|
||||||
|
|
||||||
class SeverityDetail(generics.RetrieveUpdateDestroyAPIView):
|
class SeverityDetail(generics.RetrieveUpdateDestroyAPIView):
|
||||||
|
@ -266,7 +276,8 @@ class IssueStatusList(generics.ListCreateAPIView):
|
||||||
permission_classes = (IsAuthenticated,)
|
permission_classes = (IsAuthenticated,)
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return self.model.objects.filter(project__members=self.request.user)
|
qs = self.model.objects.filter(project__members=self.request.user)
|
||||||
|
return qs.distinct()
|
||||||
|
|
||||||
|
|
||||||
class IssueStatusDetail(generics.RetrieveUpdateDestroyAPIView):
|
class IssueStatusDetail(generics.RetrieveUpdateDestroyAPIView):
|
||||||
|
@ -282,7 +293,8 @@ class TaskStatusList(SimpleFilterMixin, generics.ListCreateAPIView):
|
||||||
permission_classes = (IsAuthenticated,)
|
permission_classes = (IsAuthenticated,)
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return self.model.objects.filter(project__members=self.request.user)
|
qs = self.model.objects.filter(project__members=self.request.user)
|
||||||
|
return qs.distinct()
|
||||||
|
|
||||||
|
|
||||||
class TaskStatusDetail(generics.RetrieveUpdateDestroyAPIView):
|
class TaskStatusDetail(generics.RetrieveUpdateDestroyAPIView):
|
||||||
|
@ -298,7 +310,8 @@ class UserStoryStatusList(generics.ListCreateAPIView):
|
||||||
permission_classes = (IsAuthenticated,)
|
permission_classes = (IsAuthenticated,)
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return self.model.objects.filter(project__members=self.request.user)
|
qs = self.model.objects.filter(project__members=self.request.user)
|
||||||
|
return qs.distinct()
|
||||||
|
|
||||||
|
|
||||||
class UserStoryStatusDetail(generics.RetrieveUpdateDestroyAPIView):
|
class UserStoryStatusDetail(generics.RetrieveUpdateDestroyAPIView):
|
||||||
|
@ -314,7 +327,8 @@ class PriorityList(generics.ListCreateAPIView):
|
||||||
permission_classes = (IsAuthenticated,)
|
permission_classes = (IsAuthenticated,)
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return self.model.objects.filter(project__members=self.request.user)
|
qs = self.model.objects.filter(project__members=self.request.user)
|
||||||
|
return qs.distinct()
|
||||||
|
|
||||||
|
|
||||||
class PriorityDetail(generics.RetrieveUpdateDestroyAPIView):
|
class PriorityDetail(generics.RetrieveUpdateDestroyAPIView):
|
||||||
|
@ -330,7 +344,8 @@ class IssueTypeList(generics.ListCreateAPIView):
|
||||||
permission_classes = (IsAuthenticated,)
|
permission_classes = (IsAuthenticated,)
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return self.model.objects.filter(project__members=self.request.user)
|
qs = self.model.objects.filter(project__members=self.request.user)
|
||||||
|
return qs.distinct()
|
||||||
|
|
||||||
|
|
||||||
class IssueTypeDetail(generics.RetrieveUpdateDestroyAPIView):
|
class IssueTypeDetail(generics.RetrieveUpdateDestroyAPIView):
|
||||||
|
@ -346,7 +361,8 @@ class PointsList(generics.ListCreateAPIView):
|
||||||
permission_classes = (IsAuthenticated,)
|
permission_classes = (IsAuthenticated,)
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return self.model.objects.filter(project__members=self.request.user)
|
qs = self.model.objects.filter(project__members=self.request.user)
|
||||||
|
return qs.distinct()
|
||||||
|
|
||||||
|
|
||||||
class PointsDetail(generics.RetrieveUpdateDestroyAPIView):
|
class PointsDetail(generics.RetrieveUpdateDestroyAPIView):
|
||||||
|
|
|
@ -232,9 +232,9 @@ class Project(models.Model, WatchedMixin):
|
||||||
verbose_name_plural = u'projects'
|
verbose_name_plural = u'projects'
|
||||||
ordering = ['name']
|
ordering = ['name']
|
||||||
permissions = (
|
permissions = (
|
||||||
('can_list_projects', 'Can list projects'),
|
('list_projects', 'Can list projects'),
|
||||||
('can_view_project', 'Can view project'),
|
('view_project', 'Can view project'),
|
||||||
('can_manage_users', 'Can manage users'),
|
('manage_users', 'Can manage users'),
|
||||||
)
|
)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
|
@ -332,7 +332,7 @@ class Milestone(models.Model, WatchedMixin):
|
||||||
ordering = ['project', '-created_date']
|
ordering = ['project', '-created_date']
|
||||||
unique_together = ('name', 'project')
|
unique_together = ('name', 'project')
|
||||||
permissions = (
|
permissions = (
|
||||||
('can_view_milestone', 'Can view milestones'),
|
('view_milestone', 'Can view milestones'),
|
||||||
)
|
)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
|
@ -476,11 +476,10 @@ class UserStory(WatchedMixin, models.Model):
|
||||||
ordering = ['project', 'order']
|
ordering = ['project', 'order']
|
||||||
unique_together = ('ref', 'project')
|
unique_together = ('ref', 'project')
|
||||||
permissions = (
|
permissions = (
|
||||||
('can_comment_userstory', 'Can comment user stories'),
|
('comment_userstory', 'Can comment user stories'),
|
||||||
('can_view_userstory', 'Can view user stories'),
|
('view_userstory', 'Can view user stories'),
|
||||||
('can_change_owned_userstory', 'Can modify owned user stories'),
|
('change_owned_userstory', 'Can modify owned user stories'),
|
||||||
('can_delete_userstory', 'Can delete user stories'),
|
('add_userstory_to_milestones', 'Can add user stories to milestones'),
|
||||||
('can_add_userstory_to_milestones', 'Can add user stories to milestones'),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
|
@ -592,14 +591,14 @@ class Task(models.Model, WatchedMixin):
|
||||||
ordering = ['project', 'created_date']
|
ordering = ['project', 'created_date']
|
||||||
unique_together = ('ref', 'project')
|
unique_together = ('ref', 'project')
|
||||||
permissions = (
|
permissions = (
|
||||||
('can_comment_task', 'Can comment tasks'),
|
('comment_task', 'Can comment tasks'),
|
||||||
('can_change_owned_task', 'Can modify owned tasks'),
|
('change_owned_task', 'Can modify owned tasks'),
|
||||||
('can_change_assigned_task', 'Can modify assigned tasks'),
|
('change_assigned_task', 'Can modify assigned tasks'),
|
||||||
('can_assign_task_to_other', 'Can assign tasks to others'),
|
('assign_task_to_other', 'Can assign tasks to others'),
|
||||||
('can_assign_task_to_myself', 'Can assign tasks to myself'),
|
('assign_task_to_myself', 'Can assign tasks to myself'),
|
||||||
('can_change_task_state', 'Can change the task state'),
|
('change_task_state', 'Can change the task state'),
|
||||||
('can_view_task', 'Can view the task'),
|
('view_task', 'Can view the task'),
|
||||||
('can_add_task_to_us', 'Can add tasks to a user story'),
|
('add_task_to_us', 'Can add tasks to a user story'),
|
||||||
)
|
)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
|
@ -685,13 +684,13 @@ class Issue(models.Model, WatchedMixin):
|
||||||
ordering = ['project', 'created_date']
|
ordering = ['project', 'created_date']
|
||||||
unique_together = ('ref', 'project')
|
unique_together = ('ref', 'project')
|
||||||
permissions = (
|
permissions = (
|
||||||
('can_comment_issue', 'Can comment issues'),
|
('comment_issue', 'Can comment issues'),
|
||||||
('can_change_owned_issue', 'Can modify owned issues'),
|
('change_owned_issue', 'Can modify owned issues'),
|
||||||
('can_change_assigned_issue', 'Can modify assigned issues'),
|
('change_assigned_issue', 'Can modify assigned issues'),
|
||||||
('can_assign_issue_to_other', 'Can assign issues to others'),
|
('assign_issue_to_other', 'Can assign issues to others'),
|
||||||
('can_assign_issue_to_myself', 'Can assign issues to myself'),
|
('assign_issue_to_myself', 'Can assign issues to myself'),
|
||||||
('can_change_issue_state', 'Can change the issue state'),
|
('change_issue_state', 'Can change the issue state'),
|
||||||
('can_view_issue', 'Can view the issue'),
|
('view_issue', 'Can view the issue'),
|
||||||
)
|
)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
|
|
|
@ -4,117 +4,117 @@ from greenmine.base.permissions import BaseDetailPermission
|
||||||
|
|
||||||
|
|
||||||
class ProjectDetailPermission(BaseDetailPermission):
|
class ProjectDetailPermission(BaseDetailPermission):
|
||||||
get_permission = "can_view_project"
|
get_permission = "view_project"
|
||||||
put_permission = "can_change_project"
|
put_permission = "change_project"
|
||||||
patch_permission = "can_change_project"
|
patch_permission = "change_project"
|
||||||
delete_permission = "can_delete_project"
|
delete_permission = "delete_project"
|
||||||
safe_methods = ['HEAD', 'OPTIONS']
|
safe_methods = ['HEAD', 'OPTIONS']
|
||||||
path_to_project = []
|
path_to_project = []
|
||||||
|
|
||||||
|
|
||||||
class MilestoneDetailPermission(BaseDetailPermission):
|
class MilestoneDetailPermission(BaseDetailPermission):
|
||||||
get_permission = "can_view_milestone"
|
get_permission = "view_milestone"
|
||||||
put_permission = "can_change_milestone"
|
put_permission = "change_milestone"
|
||||||
patch_permission = "can_change_milestone"
|
patch_permission = "change_milestone"
|
||||||
delete_permission = "can_delete_milestone"
|
delete_permission = "delete_milestone"
|
||||||
safe_methods = ['HEAD', 'OPTIONS']
|
safe_methods = ['HEAD', 'OPTIONS']
|
||||||
path_to_project = ['project']
|
path_to_project = ['project']
|
||||||
|
|
||||||
|
|
||||||
class UserStoryDetailPermission(BaseDetailPermission):
|
class UserStoryDetailPermission(BaseDetailPermission):
|
||||||
get_permission = "can_view_userstory"
|
get_permission = "view_userstory"
|
||||||
put_permission = "change_userstory"
|
put_permission = "change_userstory"
|
||||||
patch_permission = "change_userstory"
|
patch_permission = "change_userstory"
|
||||||
delete_permission = "can_delete_userstory"
|
delete_permission = "delete_userstory"
|
||||||
safe_methods = ['HEAD', 'OPTIONS']
|
safe_methods = ['HEAD', 'OPTIONS']
|
||||||
path_to_project = ['project']
|
path_to_project = ['project']
|
||||||
|
|
||||||
|
|
||||||
class TaskDetailPermission(BaseDetailPermission):
|
class TaskDetailPermission(BaseDetailPermission):
|
||||||
get_permission = "can_view_task"
|
get_permission = "view_task"
|
||||||
put_permission = "can_change_task"
|
put_permission = "change_task"
|
||||||
patch_permission = "can_change_task"
|
patch_permission = "change_task"
|
||||||
delete_permission = "can_delete_task"
|
delete_permission = "delete_task"
|
||||||
safe_methods = ['HEAD', 'OPTIONS']
|
safe_methods = ['HEAD', 'OPTIONS']
|
||||||
path_to_project = ['project']
|
path_to_project = ['project']
|
||||||
|
|
||||||
|
|
||||||
class IssueDetailPermission(BaseDetailPermission):
|
class IssueDetailPermission(BaseDetailPermission):
|
||||||
get_permission = "can_view_issue"
|
get_permission = "view_issue"
|
||||||
put_permission = "can_change_issue"
|
put_permission = "change_issue"
|
||||||
patch_permission = "can_change_issue"
|
patch_permission = "change_issue"
|
||||||
delete_permission = "can_delete_issue"
|
delete_permission = "delete_issue"
|
||||||
safe_methods = ['HEAD', 'OPTIONS']
|
safe_methods = ['HEAD', 'OPTIONS']
|
||||||
path_to_project = ['project']
|
path_to_project = ['project']
|
||||||
|
|
||||||
|
|
||||||
class AttachmentDetailPermission(BaseDetailPermission):
|
class AttachmentDetailPermission(BaseDetailPermission):
|
||||||
get_permission = "can_view_attachment"
|
get_permission = "view_attachment"
|
||||||
put_permission = "can_change_attachment"
|
put_permission = "change_attachment"
|
||||||
patch_permission = "can_change_attachment"
|
patch_permission = "change_attachment"
|
||||||
delete_permission = "can_delete_attachment"
|
delete_permission = "delete_attachment"
|
||||||
safe_methods = ['HEAD', 'OPTIONS']
|
safe_methods = ['HEAD', 'OPTIONS']
|
||||||
path_to_project = ['change', 'project']
|
path_to_project = ['project']
|
||||||
|
|
||||||
|
|
||||||
class SeverityDetailPermission(BaseDetailPermission):
|
class SeverityDetailPermission(BaseDetailPermission):
|
||||||
get_permission = "can_view_severity"
|
get_permission = "view_severity"
|
||||||
put_permission = "can_change_severity"
|
put_permission = "change_severity"
|
||||||
patch_permission = "can_change_severity"
|
patch_permission = "change_severity"
|
||||||
delete_permission = "can_delete_severity"
|
delete_permission = "delete_severity"
|
||||||
safe_methods = ['HEAD', 'OPTIONS']
|
safe_methods = ['HEAD', 'OPTIONS']
|
||||||
path_to_project = ['project']
|
path_to_project = ['project']
|
||||||
|
|
||||||
|
|
||||||
class IssueStatusDetailPermission(BaseDetailPermission):
|
class IssueStatusDetailPermission(BaseDetailPermission):
|
||||||
get_permission = "can_view_issuestatus"
|
get_permission = "view_issuestatus"
|
||||||
put_permission = "can_change_issuestatus"
|
put_permission = "change_issuestatus"
|
||||||
patch_permission = "can_change_issuestatus"
|
patch_permission = "change_issuestatus"
|
||||||
delete_permission = "can_delete_issuestatus"
|
delete_permission = "delete_issuestatus"
|
||||||
safe_methods = ['HEAD', 'OPTIONS']
|
safe_methods = ['HEAD', 'OPTIONS']
|
||||||
path_to_project = ['project']
|
path_to_project = ['project']
|
||||||
|
|
||||||
|
|
||||||
class TaskStatusDetailPermission(BaseDetailPermission):
|
class TaskStatusDetailPermission(BaseDetailPermission):
|
||||||
get_permission = "can_view_taskstatus"
|
get_permission = "view_taskstatus"
|
||||||
put_permission = "can_change_taskstatus"
|
put_permission = "change_taskstatus"
|
||||||
patch_permission = "can_change_taskstatus"
|
patch_permission = "change_taskstatus"
|
||||||
delete_permission = "can_delete_taskstatus"
|
delete_permission = "delete_taskstatus"
|
||||||
safe_methods = ['HEAD', 'OPTIONS']
|
safe_methods = ['HEAD', 'OPTIONS']
|
||||||
path_to_project = ['project']
|
path_to_project = ['project']
|
||||||
|
|
||||||
|
|
||||||
class UserStoryStatusDetailPermission(BaseDetailPermission):
|
class UserStoryStatusDetailPermission(BaseDetailPermission):
|
||||||
get_permission = "can_view_userstorystatus"
|
get_permission = "view_userstorystatus"
|
||||||
put_permission = "can_change_userstorystatus"
|
put_permission = "change_userstorystatus"
|
||||||
patch_permission = "can_change_userstorystatus"
|
patch_permission = "change_userstorystatus"
|
||||||
delete_permission = "can_delete_userstorystatus"
|
delete_permission = "delete_userstorystatus"
|
||||||
safe_methods = ['HEAD', 'OPTIONS']
|
safe_methods = ['HEAD', 'OPTIONS']
|
||||||
path_to_project = ['project']
|
path_to_project = ['project']
|
||||||
|
|
||||||
|
|
||||||
class PriorityDetailPermission(BaseDetailPermission):
|
class PriorityDetailPermission(BaseDetailPermission):
|
||||||
get_permission = "can_view_priority"
|
get_permission = "view_priority"
|
||||||
put_permission = "can_change_priority"
|
put_permission = "change_priority"
|
||||||
patch_permission = "can_change_priority"
|
patch_permission = "change_priority"
|
||||||
delete_permission = "can_delete_priority"
|
delete_permission = "delete_priority"
|
||||||
safe_methods = ['HEAD', 'OPTIONS']
|
safe_methods = ['HEAD', 'OPTIONS']
|
||||||
path_to_project = ['project']
|
path_to_project = ['project']
|
||||||
|
|
||||||
|
|
||||||
class IssueTypeDetailPermission(BaseDetailPermission):
|
class IssueTypeDetailPermission(BaseDetailPermission):
|
||||||
get_permission = "can_view_issuetype"
|
get_permission = "view_issuetype"
|
||||||
put_permission = "can_severity_issuetype"
|
put_permission = "severity_issuetype"
|
||||||
patch_permission = "can_severity_issuetype"
|
patch_permission = "severity_issuetype"
|
||||||
delete_permission = "can_delete_issuetype"
|
delete_permission = "delete_issuetype"
|
||||||
safe_methods = ['HEAD', 'OPTIONS']
|
safe_methods = ['HEAD', 'OPTIONS']
|
||||||
path_to_project = ['project']
|
path_to_project = ['project']
|
||||||
|
|
||||||
|
|
||||||
class PointsDetailPermission(BaseDetailPermission):
|
class PointsDetailPermission(BaseDetailPermission):
|
||||||
get_permission = "can_view_points"
|
get_permission = "view_points"
|
||||||
put_permission = "can_severity_points"
|
put_permission = "severity_points"
|
||||||
patch_permission = "can_severity_points"
|
patch_permission = "severity_points"
|
||||||
delete_permission = "can_delete_points"
|
delete_permission = "delete_points"
|
||||||
safe_methods = ['HEAD', 'OPTIONS']
|
safe_methods = ['HEAD', 'OPTIONS']
|
||||||
path_to_project = ['project']
|
path_to_project = ['project']
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
# -* coding: utf-8 -*-
|
# -* coding: utf-8 -*-
|
||||||
|
|
||||||
from haystack import indexes
|
from haystack import indexes
|
||||||
from greenmine.scrum.models import UserStory, Task
|
from greenmine.scrum.models import UserStory, Task, Issue
|
||||||
|
|
||||||
|
|
||||||
class UserStoryIndex(indexes.SearchIndex, indexes.Indexable):
|
class UserStoryIndex(indexes.SearchIndex, indexes.Indexable):
|
||||||
text = indexes.CharField(document=True, use_template=True,
|
text = indexes.CharField(document=True, use_template=True,
|
||||||
template_name='search/indexes/userstory_text.txt')
|
template_name='search/indexes/userstory_text.txt')
|
||||||
title = indexes.CharField(model_attr='subject')
|
title = indexes.CharField(model_attr='subject')
|
||||||
|
project_id = indexes.IntegerField(model_attr="project_id")
|
||||||
|
description = indexes.CharField(model_attr="description")
|
||||||
|
|
||||||
def get_model(self):
|
def get_model(self):
|
||||||
return UserStory
|
return UserStory
|
||||||
|
@ -20,9 +22,25 @@ class TaskIndex(indexes.SearchIndex, indexes.Indexable):
|
||||||
text = indexes.CharField(document=True, use_template=True,
|
text = indexes.CharField(document=True, use_template=True,
|
||||||
template_name='search/indexes/task_text.txt')
|
template_name='search/indexes/task_text.txt')
|
||||||
title = indexes.CharField(model_attr='subject')
|
title = indexes.CharField(model_attr='subject')
|
||||||
|
project_id = indexes.IntegerField(model_attr="project_id")
|
||||||
|
description = indexes.CharField(model_attr="description")
|
||||||
|
|
||||||
def get_model(self):
|
def get_model(self):
|
||||||
return Task
|
return Task
|
||||||
|
|
||||||
def index_queryset(self, using=None):
|
def index_queryset(self, using=None):
|
||||||
return self.get_model().objects.all()
|
return self.get_model().objects.all()
|
||||||
|
|
||||||
|
|
||||||
|
class IssueIndex(indexes.SearchIndex, indexes.Indexable):
|
||||||
|
text = indexes.CharField(document=True, use_template=True,
|
||||||
|
template_name='search/indexes/issue_text.txt')
|
||||||
|
title = indexes.CharField(model_attr='subject')
|
||||||
|
project_id = indexes.IntegerField(model_attr="project_id")
|
||||||
|
description = indexes.CharField(model_attr="description")
|
||||||
|
|
||||||
|
def get_model(self):
|
||||||
|
return Issue
|
||||||
|
|
||||||
|
def index_queryset(self, using=None):
|
||||||
|
return self.get_model().objects.all()
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
{{ object.uuid }}
|
||||||
|
{{ object.user_story }}
|
||||||
|
{{ object.ref }}
|
||||||
|
{{ object.status }}
|
||||||
|
{{ object.owner }}
|
||||||
|
{{ object.milestone }}
|
||||||
|
{{ object.project }}
|
||||||
|
{{ object.type }}
|
||||||
|
{{ object.created_date }}
|
||||||
|
{{ object.modified_date }}
|
||||||
|
{{ object.finished_date }}
|
||||||
|
{{ object.last_status }}
|
||||||
|
{{ object.subject }}
|
||||||
|
{{ object.description }}
|
||||||
|
{{ object.assigned_to }}
|
||||||
|
{% for watcher in object.watchers.all %}
|
||||||
|
{{ watcher }}
|
||||||
|
{% endfor %}
|
||||||
|
{% for tag in object.tags.all %}
|
||||||
|
{{ tag }}
|
||||||
|
{% endfor %}
|
|
@ -30,8 +30,8 @@ class WikiPage(models.Model):
|
||||||
unique_together = ('project', 'slug',)
|
unique_together = ('project', 'slug',)
|
||||||
|
|
||||||
permissions = (
|
permissions = (
|
||||||
('can_view_wikipage', 'Can modify owned wiki pages'),
|
('view_wikipage', 'Can modify owned wiki pages'),
|
||||||
('can_change_owned_wikipage', 'Can modify owned wiki pages'),
|
('change_owned_wikipage', 'Can modify owned wiki pages'),
|
||||||
)
|
)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
|
|
Loading…
Reference in New Issue