Skip to content

Commit

Permalink
fixing conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
meomancer committed Jul 22, 2016
2 parents c1fa939 + cfaeacf commit b69cc30
Show file tree
Hide file tree
Showing 27 changed files with 479 additions and 205 deletions.
4 changes: 3 additions & 1 deletion deployment/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ MAINTAINER Tim Sutton<[email protected]>
ADD 71-apt-cacher-ng /etc/apt/apt.conf.d/71-apt-cacher-ng

# Pandoc needed to generate rst dumps, uic compressor needed for django-pipeline
RUN apt-get update -y; apt-get -y --force-yes install yui-compressor pandoc
RUN apt-get update -y; apt-get -y --force-yes install yui-compressor
RUN wget https://github.com/jgm/pandoc/releases/download/1.17.1/pandoc-1.17.1-2-amd64.deb
RUN dpkg -i pandoc-1.17.1-2-amd64.deb

ADD REQUIREMENTS.txt /REQUIREMENTS.txt
RUN pip install -r /REQUIREMENTS.txt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,13 @@ <h3 class="panel-title">
{% endif %}
<h4 class="text-muted">
Latest Versions
<a href="{% url 'version-create' project_slug=project.slug %}"
class="btn btn-default pull-right btn-sm tooltip-toggle"
data-title="Create New Version">
{% show_button_icon "add" %}
</a>
{% if project.approved %}
<a href="{% url 'version-create' project_slug=project.slug %}"
class="btn btn-default pull-right btn-sm tooltip-toggle"
data-title="Create New Version">
{% show_button_icon "add" %}
</a>
{% endif %}
</h4>
<hr/>
{% if project.versions %}
Expand Down
3 changes: 2 additions & 1 deletion django_project/base/templatetags/custom_markup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def show_button_icon(context, value):
context_icon = {
'add': 'glyphicon glyphicon-asterisk',
'update': 'glyphicon glyphicon-pencil',
'delete': 'glyphicon glyphicon-minus'
'delete': 'glyphicon glyphicon-minus',
'back': 'glyphicon glyphicon-arrow-left'
}

return {
Expand Down
5 changes: 4 additions & 1 deletion django_project/base/views/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,10 @@ def get_queryset(self):
return qs.filter(owner=self.request.user)

def get_success_url(self):
return reverse('project-detail', kwargs={'slug': self.object.slug})
if self.object.approved:
return reverse('project-detail', kwargs={'slug': self.object.slug})
else:
return reverse('pending-project-list')

def form_valid(self, form):
"""Check that there is no referential integrity error when saving."""
Expand Down
20 changes: 17 additions & 3 deletions django_project/changes/forms.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# coding=utf-8
from django import forms
from django.core.validators import ValidationError
from crispy_forms.helper import FormHelper
from crispy_forms.layout import (
Layout,
Expand Down Expand Up @@ -46,6 +47,20 @@ def save(self, commit=True):
instance.save()
return instance

def clean(self):
cleaned_data = self.cleaned_data

try:
Category.objects.get(name=cleaned_data['name'], project=self.project)
except Category.DoesNotExist:
pass
else:
raise ValidationError(
'Category with this name already exists for this project'
)

return cleaned_data


class VersionForm(forms.ModelForm):

Expand Down Expand Up @@ -129,9 +144,8 @@ def __init__(self, *args, **kwargs):
self.helper.add_input(Submit('submit', 'Submit'))
self.fields['title'].label = 'Feature Title'
# Filter the category list when editing so it shows only relevant ones
if not self.instance.id:
self.fields['category'].queryset = Category.objects.filter(
project=self.project).order_by('name')
self.fields['category'].queryset = Category.objects.filter(
project=self.project).order_by('name')

def save(self, commit=True):
instance = super(EntryForm, self).save(commit=False)
Expand Down
6 changes: 3 additions & 3 deletions django_project/changes/models/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
from common.utilities import version_slugify
import os
import logging
from core.settings.contrib import STOP_WORDS
from django.conf.global_settings import MEDIA_ROOT
from django.db import models
from .entry import Entry
from .sponsorship_period import SponsorshipPeriod
from core.settings.contrib import STOP_WORDS
from django.conf.global_settings import MEDIA_ROOT
from django.contrib.auth.models import User
from django.utils.translation import ugettext_lazy as _
from django.db import models

logger = logging.getLogger(__name__)

Expand Down
81 changes: 81 additions & 0 deletions django_project/changes/static/js/category.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/**
* Created by Dimas Ciputra <[email protected]> on 22/07/16.
*/

var sortable_state = 'enabled';

$("#sortable").sortable({
stop: onStopSortable
});

function onStopSortable(e, ui) {
var categories = $.map($(this).find('li'), function(el, i){
var cat = String(el.id).split('-');
return {
'sort_number' : i,
'id': cat[0],
'name': cat[1]
}
});
sortableDisable();

var data_url = $("#sortable").data("url");

if(data_url) {
$.ajax({
url: data_url,
type: "POST",
data: JSON.stringify(categories),
success: function (response) {
sortableEnable();
if($('#order-saved').is(":visible"))
{
$('#order-saved').hide();
showOrderSaved();
} else {
showOrderSaved();
}
},
error: function (response) {
console.log(response);
sortableEnable();
if($('#order-not-saved').is(":visible"))
{
$('#order-not-saved').hide();
showOrderNotSaved();
} else {
showOrderNotSaved();
}
}

});
}

}

function showOrderSaved() {
$('#order-saved').fadeIn( "fast", function() {
$('#order-saved').fadeOut(2000);
});
}

function showOrderNotSaved() {
$('#order-not-saved').fadeIn( "fast", function() {
$('#order-not-saved').fadeOut(2000);
});
}

function sortableEnable() {
sortable_state = 'enabled';
$("#sortable").sortable({
stop: onStopSortable
});
$("#sortable").sortable("option", "disabled", false );
$("#sortable").disableSelection();
return false;
}
function sortableDisable() {
sortable_state = 'disabled';
$( "#sortable" ).sortable("disable");
return false;
}
17 changes: 17 additions & 0 deletions django_project/changes/static/js/entry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Created by Dimas Ciputra <[email protected]> on 15/07/16.
*/

$(".pop-image").on("click", function() {
$('#imagepreview').attr('src', $(this).children().attr('id'));
$('#image-url').attr('href', $(this).children().attr('id'));
$('#imagemodal').modal('show');
return false;
});

$(".pop-gif").on("click", function() {
$('#imagepreview').attr('src', $(this).siblings().attr('id'));
$('#image-url').attr('href', $(this).siblings().attr('id'));
$('#imagemodal').modal('show');
return false;
});
46 changes: 35 additions & 11 deletions django_project/changes/templates/category/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,29 @@ <h1 class="text-muted">
data-title="View Pending Categories">
<span class="glyphicon glyphicon-time"></span>
</a>
{% else %}
<a class="btn btn-default btn-mini tooltip-toggle"
href='{% url "category-list" project_slug %}'
data-title="View Categories">
<span class="glyphicon glyphicon-th-list"></span>
</a>
{% endif %}
{% if user.is_staff %}
<a class="btn btn-default btn-mini tooltip-toggle"
href='{% url "category-order" project_slug %}'
data-title="Order Categories">
<span class="glyphicon glyphicon-sort-by-order"></span>
</a>
{% endif %}
<a class="btn btn-default btn-mini tooltip-toggle"
href='{% url "category-order" project_slug %}'
data-title="Order Categories">
<span class="glyphicon glyphicon-sort-by-order"></span>
</a>
</div>
<span id="order-saved" hidden class="alert alert-success" style="font-size: 9pt; padding: 3px;font-style: italic;">
order saved</span>
<span id="order-not-saved" hidden class="alert alert-danger" style="font-size: 9pt; padding: 3px;font-style: italic;">
order not saved</span>
{% endif %}
</h1>
</div>

{% ifequal num_categories 0 %}
{% if unapproved %}
<h3>All categories are approved.</h3>
Expand All @@ -48,12 +61,17 @@ <h3>No categories are defined, but you can <a
href='{% url "category-create" project_slug %}'>create one</a>.</h3>
{% endif %}
{% endifequal %}

{% if user.is_authenticated and user.is_staff %}
<ul id="sortable" data-url="{% url "category-submit-order" project_slug %}">
{% else %}
<ul>
{% endif %}

{% for category in categories %}
<script>console.debug("{{ category }}");</script>
<div class="row" style="margin-top:10px;">
<li class="row order" style="margin-top:10px;" id="{{ category.id }}-{{ category.name }}">
<div class="col-lg-10">
<h5>{{ category.project.name }}</h5>
<h3>{{ category.name }}</h3>
<h4>{{ category.name }}</h4>
</div>
<div class="col-lg-2">
<div class="btn-group pull-right">
Expand All @@ -77,8 +95,14 @@ <h3>{{ category.name }}</h3>
</a>
</div>
</div>
</div>
</li>
{% endfor %}

</ul>
<hr />
{% include "_pagination.html" %}

<script>

</script>

{% endblock %}
79 changes: 1 addition & 78 deletions django_project/changes/templates/category/order.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ <h1 class="text-muted">
{% ifequal num_categories 0 %}
<h3>No categories are defined, but you can</h3>
{% endifequal %}
<ul id="sortable" >
<ul id="sortable" data-url="{% url "category-submit-order" project_slug %}">
{% for category in categories %}
<script>console.debug("{{ category }}");</script>
<li class="row order" style="margin-top:6px;" id="{{ category.id }}-{{ category.name }}" >
<div class="col-lg-1" style="padding-top: 10px;">
{% if category.image_file %}
Expand All @@ -53,81 +52,5 @@ <h3>No categories are defined, but you can</h3>
</ul>
<hr />

<script>
var sortable_state = 'enabled';

$("#sortable").sortable({
stop: onStopSortable
});

function onStopSortable(e, ui) {
var categories = $.map($(this).find('li'), function(el, i){
var cat = String(el.id).split('-');
return {
'sort_number' : i,
'id': cat[0],
'name': cat[1]
}
});
sortableDisable();

$.ajax({
url: "{% url "category-submit-order" project_slug %}",
type: "POST",
data: JSON.stringify(categories),
success: function (response) {
sortableEnable();
if($('#order-saved').is(":visible"))
{
$('#order-saved').hide();
showOrderSaved();
} else {
showOrderSaved();
}
},
error: function (response) {
console.log(response);
sortableEnable();
if($('#order-not-saved').is(":visible"))
{
$('#order-not-saved').hide();
showOrderNotSaved();
} else {
showOrderNotSaved();
}
}

});
}

function showOrderSaved() {
$('#order-saved').fadeIn( "fast", function() {
$('#order-saved').fadeOut(2000);
});
}

function showOrderNotSaved() {
$('#order-not-saved').fadeIn( "fast", function() {
$('#order-not-saved').fadeOut(2000);
});
}

function sortableEnable() {
sortable_state = 'enabled';
$("#sortable").sortable({
stop: onStopSortable
});
$("#sortable").sortable("option", "disabled", false );
// ^^^ this is required otherwise re-enabling sortable will not work!
$("#sortable").disableSelection();
return false;
}
function sortableDisable() {
sortable_state = 'disabled';
$( "#sortable" ).sortable("disable");
return false;
}
</script>

{% endblock %}

2 changes: 2 additions & 0 deletions django_project/changes/templates/entry/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ <h4 class="muted">Version:
<h5 id="comments">Comments</h5>
{% disqus_show_comments %}


{% endblock %}

Loading

0 comments on commit b69cc30

Please sign in to comment.