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