-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add document archive settings page.
* Remove the unneeded not null constraints on the organization model.
- Loading branch information
Showing
12 changed files
with
169 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
django_kala/projects/templates/documents/settings/archive.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
{% extends 'base.html' %} | ||
{% load static %} | ||
{% load kala_tags %} | ||
|
||
{% block content %} | ||
<div class="repo ribbon"> | ||
<div class="ui container"> | ||
<div class="ui big breadcrumb"> | ||
<a class="section" href="{% url 'organizations:organization' project.organization.pk %}">{{ project.organization }}</a> | ||
<div class="divider"> /</div> | ||
<a class="section" href="{% url 'projects:project' project.pk %}">{{ project }}</a> | ||
<div class="divider"> /</div> | ||
<span class="active section">{{ document }}</span> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="ui tabular menu"> | ||
<div class="ui container"> | ||
<a class="item" href="{% url 'projects:project' project.pk %}"> | ||
<i class="book icon"></i> | ||
Documents | ||
</a> | ||
{# <a class="item">#} | ||
{# <i class="issue opened icon"></i>#} | ||
{# Issues#} | ||
{# <span class="ui small label">593</span>#} | ||
{# </a>#} | ||
<a class="active item" href="{% url 'projects:details' project.pk %}"> | ||
<i class="gear icon"></i> | ||
Settings | ||
</a> | ||
</div> | ||
</div> | ||
|
||
|
||
<div class="ui two column grid container"> | ||
<div class="four wide column"> | ||
<div class="four wide column"> | ||
<div class="ui vertical menu"> | ||
<div class="item"> | ||
<div class="header">Document</div> | ||
<div class="menu"> | ||
<a class="item" href="{% url 'projects:document_details' document.project.pk document.pk %}">Details</a> | ||
<a class="item active" href="{% url 'projects:document_archive' document.project.pk document.pk %}">Archive</a> | ||
</div> | ||
</div> | ||
<div class="item"> | ||
<div class="header">People</div> | ||
<div class="menu"> | ||
<a class="item" href="{% url 'projects:document_manage_access' document.project.pk document.pk %}">Manage access</a> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="twelve wide column"> | ||
<form class="ui form" method="post"> | ||
{% csrf_token %} | ||
<div class="field"> | ||
<label>Re-enter projects name to archive the project</label> | ||
<input id="projectName" type="text" name="documentName" placeholder="Document Name" required> | ||
</div> | ||
<div class="ui error message"></div> | ||
<div class="ui submit button primary">Archive document</div> | ||
</form> | ||
</div> | ||
</div> | ||
{% endblock content %} | ||
|
||
{% block scripts %} | ||
<script> | ||
$('.ui.form') | ||
.form({ | ||
fields: { | ||
projectName: { | ||
rules: [ | ||
{ | ||
type: 'isExactly[{{ document.name }}]', | ||
prompt: 'You must enter the documentpytho name as it appears in the application.' | ||
} | ||
] | ||
} | ||
} | ||
}) | ||
; | ||
</script> | ||
{% endblock scripts %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from django.contrib.auth.mixins import LoginRequiredMixin | ||
from django.core.exceptions import PermissionDenied | ||
from django.shortcuts import get_object_or_404, redirect | ||
from django.urls import reverse | ||
from django.views.generic.base import TemplateView | ||
|
||
from documents.models import Document | ||
|
||
|
||
class ArchiveView(LoginRequiredMixin, TemplateView): | ||
template_name = 'documents/settings/archive.html' | ||
|
||
def get_context_data(self, **kwargs): | ||
return { | ||
'document': self.document, | ||
'project': self.project, | ||
'can_create': self.project.has_change(self.request.user) or self.project.has_create(self.request.user), | ||
'can_invite': self.project.organization.has_change(self.request.user) or self.project.organization.has_create(self.request.user) | ||
} | ||
|
||
def dispatch(self, request, project_pk, document_pk, *args, **kwargs): | ||
self.document = get_object_or_404( | ||
Document.objects.active().select_related( | ||
'project', | ||
'project__organization' | ||
), | ||
pk=document_pk | ||
) | ||
if not self.document.has_delete(request.user): | ||
raise PermissionDenied('You do not have permission to archive this document') | ||
self.project = self.document.project | ||
|
||
return super(ArchiveView, self).dispatch(request, *args, **kwargs) | ||
|
||
def post(self, request, *args, **kwargs): | ||
self.document.set_active(False) | ||
return redirect( | ||
reverse( | ||
'projects:document_archive', | ||
args=[ | ||
self.document.project.pk, | ||
self.document.pk | ||
] | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters