-
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 categories to the project settings.
- Loading branch information
Showing
13 changed files
with
545 additions
and
87 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from django import forms | ||
|
||
from projects.models import Category | ||
|
||
|
||
class CategoryForm(forms.ModelForm): | ||
def __init__(self, *args, **kwargs): | ||
self.project = kwargs.pop('project') | ||
super(CategoryForm, self).__init__(*args, **kwargs) | ||
|
||
class Meta: | ||
model = Category | ||
fields = ['name'] | ||
|
||
def save(self, commit=True): | ||
self.instance.project = self.project | ||
super(CategoryForm, self).save(commit) |
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
154 changes: 154 additions & 0 deletions
154
django_kala/projects/templates/projects/settings/categories.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,154 @@ | ||
{% 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">{{ project.organization }}</a> | ||
<div class="divider"> /</div> | ||
<a class="active section">{{ project }}</a> | ||
</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="ui vertical menu"> | ||
<div class="item"> | ||
<div class="header">Project</div> | ||
<div class="menu"> | ||
<a class="item" href="{% url 'projects:details' project.pk %}">Details</a> | ||
<a class="item" href="{% url 'projects:archive' project.pk %}">Archive</a> | ||
</div> | ||
</div> | ||
<div class="item"> | ||
<div class="header">People</div> | ||
<div class="menu"> | ||
<a class="item" href="{% url 'projects:manage_access' project.pk %}">Manage access</a> | ||
</div> | ||
</div> | ||
<div class="item"> | ||
<div class="header">Organizations</div> | ||
<div class="menu"> | ||
<a class="item" href="{% url 'projects:transfer_ownership' project.pk %}">Transfer ownership</a> | ||
</div> | ||
</div> | ||
<div class="item"> | ||
<div class="header">Categories</div> | ||
<div class="menu"> | ||
<a class="active item" href="{% url 'projects:categories' project.pk %}">Manage categories</a> | ||
<a class="item" href="{% url 'projects:new_category' project.pk %}">New category</a> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="twelve wide column"> | ||
<table class="ui celled table"> | ||
<thead> | ||
<tr> | ||
<th>Name</th> | ||
<th>Edit</th> | ||
<th>Delete</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for category in categories %} | ||
<tr> | ||
<td> | ||
{{ category.name }} | ||
</td> | ||
<td> | ||
<a href="{% url 'projects:edit_category' project.pk category.pk %}"> | ||
<button class="ui primary button">Edit</button> | ||
</a> | ||
</td> | ||
<td> | ||
<button onclick="deleteCategory({{ category.pk }});" class="ui negative button">Delete</button> | ||
</td> | ||
</tr> | ||
{% empty %} | ||
<tr> | ||
<td colspan="3">There are no categories for this project.</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
<div class="ui basic modal"> | ||
<div class="ui icon header"> | ||
<i class="organization icon"></i> | ||
Delete Category | ||
</div> | ||
<div class="content"> | ||
<p>Are you sure that you want to delete this category?</p> | ||
</div> | ||
<div class="actions"> | ||
<div class="ui green cancel inverted button"> | ||
<i class="stop icon"></i> | ||
No | ||
</div> | ||
<div class="ui red basic ok inverted button"> | ||
<i class="trashcan icon"></i> | ||
Yes | ||
</div> | ||
</div> | ||
</div> | ||
{% csrf_token %} | ||
{% endblock content %} | ||
|
||
{% block scripts %} | ||
<script> | ||
var csrftoken = jQuery("[name=csrfmiddlewaretoken]").val(); | ||
function csrfSafeMethod(method) { | ||
// these HTTP methods do not require CSRF protection | ||
return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method)); | ||
} | ||
$.ajaxSetup({ | ||
beforeSend: function(xhr, settings) { | ||
if (!csrfSafeMethod(settings.type) && !this.crossDomain) { | ||
xhr.setRequestHeader("X-CSRFToken", csrftoken); | ||
} | ||
} | ||
}); | ||
|
||
function deleteCategory(pk) { | ||
$('.ui.basic.modal') | ||
.modal({ | ||
onApprove: function () { | ||
$.ajax({ | ||
url: '{% url 'projects:categories' project.pk %}' + '/' + pk, | ||
type: 'DELETE', | ||
success: function () { | ||
location.reload(); | ||
}, | ||
error: $.noop | ||
}); | ||
} | ||
}) | ||
.modal('show') | ||
; | ||
} | ||
</script> | ||
{% endblock %} |
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
81 changes: 81 additions & 0 deletions
81
django_kala/projects/templates/projects/settings/edit_category.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,81 @@ | ||
{% 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">{{ project.organization }}</a> | ||
<div class="divider"> /</div> | ||
<a class="active section">{{ project }}</a> | ||
</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="ui vertical menu"> | ||
<div class="item"> | ||
<div class="header">Project</div> | ||
<div class="menu"> | ||
<a class="item" href="{% url 'projects:details' project.pk %}">Details</a> | ||
<a class="item" href="{% url 'projects:archive' project.pk %}">Archive</a> | ||
</div> | ||
</div> | ||
<div class="item"> | ||
<div class="header">People</div> | ||
<div class="menu"> | ||
<a class="item" href="{% url 'projects:manage_access' project.pk %}">Manage access</a> | ||
</div> | ||
</div> | ||
<div class="item"> | ||
<div class="header">Organizations</div> | ||
<div class="menu"> | ||
<a class="item" href="{% url 'projects:transfer_ownership' project.pk %}">Transfer ownership</a> | ||
</div> | ||
</div> | ||
<div class="item"> | ||
<div class="header">Categories</div> | ||
<div class="menu"> | ||
<a class="item" href="{% url 'projects:categories' project.pk %}">Manage categories</a> | ||
<a class="active item" href="{% url 'projects:new_category' project.pk %}">New category</a> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="twelve wide column"> | ||
<form class="ui form" method="post"> | ||
{% csrf_token %} | ||
<div class="field"> | ||
<label>{{ form.name.label }}</label> | ||
<input id={{ form.name.auto_id }} type="text" name="{{ form.name.name }}" placeholder="Category Name" value="{{ form.name.value }}" maxlength="{{ form.fields.name.max_length }} required"> | ||
</div> | ||
<div class="field"> | ||
<label>{{ form.type.label }}</label> | ||
{{ form.type }} | ||
</div> | ||
<button class="ui button primary" type="submit">Edit category</button> | ||
</form> | ||
</div> | ||
</div> | ||
{% endblock content %} |
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
Oops, something went wrong.