Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

create a CommonLanguageDesc abstract class and a LanguageDescModelFor…

…m for DocURL and EnableURL classes, move common template code to different files for reuse and small fixes from pull request 9
  • Loading branch information...
commit 77257926dc26c381785d3e1e4dc003ef8b5bcdf8 1 parent bfa20e7
@sergiocharpineljr sergiocharpineljr authored
View
142 ispdb/config/models.py
@@ -13,6 +13,7 @@
from django.conf import settings
from django.utils.translation import get_language_info
from django.utils.functional import curry
+from django.utils.translation.trans_real import parse_accept_lang_header
import ispdb.audit as audit
class Domain(models.Model):
@@ -188,49 +189,56 @@ class Issue(models.Model):
status = models.CharField(max_length=20, choices=STATUS_CHOICES,
default="open")
-class DocURL(models.Model):
+
+class CommonConfigURL(models.Model):
url = models.URLField(
- verbose_name="URL of the page describing these settings")
- config = models.ForeignKey(Config)
+ verbose_name="URL of the page")
+ config = models.ForeignKey(Config, related_name="%(class)s_set")
+
+ class Meta:
+ abstract = True
def __str__(self): return str(self.url)
def __unicode__(self): return self.url
-class DocURLDesc(models.Model):
+
+class CommonURLDesc(models.Model):
description = models.TextField(
max_length=100,
- verbose_name="Description of the settings page")
+ verbose_name="Description")
language = models.CharField(
max_length=10,
verbose_name="Language",
choices=settings.LANGUAGES)
- docurl = models.ForeignKey(DocURL, related_name="descriptions")
+
+ class Meta:
+ abstract = True
def __str__(self): return str(self.description)
def __unicode__(self): return self.description
-class EnableURL(models.Model):
- url = models.URLField(
- verbose_name="URL of the page with enable instructions")
- config = models.ForeignKey(Config)
+class DocURL(CommonConfigURL):
+ pass
+DocURL._meta.get_field('url').verbose_name = ("URL of the page describing "
+ "these settings")
- def __str__(self): return str(self.url)
- def __unicode__(self): return self.url
+class DocURLDesc(CommonURLDesc):
+ docurl = models.ForeignKey(DocURL, related_name="descriptions")
+DocURLDesc._meta.get_field('description').verbose_name = ('Description of the '
+ 'settings page')
-class EnableURLInst(models.Model):
- instruction = models.TextField(
- max_length=100,
- verbose_name="Instruction")
- language = models.CharField(
- max_length=10,
- verbose_name="Language",
- choices=settings.LANGUAGES)
- enableurl = models.ForeignKey(EnableURL, related_name="instructions")
- def __str__(self): return str(self.instruction)
- def __unicode__(self): return self.instruction
+class EnableURL(CommonConfigURL):
+ pass
+EnableURL._meta.get_field('url').verbose_name = ("URL of the page with enable "
+ "instructions")
+
+
+class EnableURLInst(CommonURLDesc):
+ enableurl = models.ForeignKey(EnableURL, related_name="instructions")
+EnableURLInst._meta.get_field('description').verbose_name = ('Instruction')
# Forms
@@ -272,6 +280,18 @@ def clean(self, **kwargs):
self.errors.clear()
return cleaned_data
+ def save(self, commit=True):
+ super(DynamicModelForm, self).save(commit=False)
+ if commit:
+ # delete if exists
+ if self.cleaned_data and self.cleaned_data['DELETE']:
+ if self.instance.pk:
+ return self.instance.delete()
+ else:
+ return None
+ super(DynamicModelForm, self).save()
+ return self.instance
+
class DynamicBaseModelFormSet(BaseModelFormSet):
"""
@@ -312,20 +332,18 @@ class Meta:
fields = ['title', 'description']
-class DocURLDescForm(DynamicModelForm):
- class Meta:
- model = DocURLDesc
- exclude = ['docurl']
-
+class LanguageDescModelForm(DynamicModelForm):
+ """
+ A DynamicModelForm for classes with a language and a description fields
+ """
def __init__(self, *args, **kwargs):
http_accept_language = kwargs.pop('http_accept_language', '')
- super(DocURLDescForm, self).__init__(*args, **kwargs)
- self.fields['description'].widget.attrs.update({'rows': 2, 'cols': 20})
+ super(LanguageDescModelForm, self).__init__(*args, **kwargs)
+ self.fields['description'].widget.attrs.update({'rows': 1, 'cols': 20})
choices = []
# add HTTP_ACCEPTED_LANG first
if http_accept_language:
- codes = re.split(';|,', http_accept_language)
- for code in codes:
+ for code, q in parse_accept_lang_header(http_accept_language):
try:
li = get_language_info(code)
except:
@@ -341,17 +359,11 @@ def __init__(self, *args, **kwargs):
choices.append((code, lang + ' - ' + li['name_local']))
self.fields['language'].choices = choices
- def save(self, commit=True):
- super(DocURLDescForm, self).save(commit=False)
- if commit:
- # delete if exists
- if self.cleaned_data and self.cleaned_data['DELETE']:
- if self.instance.pk:
- return self.instance.delete()
- else:
- return None
- super(DocURLDescForm, self).save()
- return self.instance
+
+class DocURLDescForm(LanguageDescModelForm):
+ class Meta:
+ model = DocURLDesc
+ exclude = ['docurl']
class BaseDocURLDescFormSet(DynamicBaseModelFormSet):
@@ -479,47 +491,11 @@ def delete(self):
form.instance.delete()
-class EnableURLInstForm(DynamicModelForm):
+class EnableURLInstForm(LanguageDescModelForm):
class Meta:
model = EnableURLInst
exclude = ['enableurl']
- def __init__(self, *args, **kwargs):
- http_accept_language = kwargs.pop('http_accept_language', '')
- super(EnableURLInstForm, self).__init__(*args, **kwargs)
- self.fields['instruction'].widget.attrs.update({'rows': 2, 'cols': 20})
- choices = []
- # add HTTP_ACCEPTED_LANG first
- if http_accept_language:
- codes = re.split(';|,', http_accept_language)
- for code in codes:
- try:
- li = get_language_info(code)
- except:
- continue
- choices.append((code, li['name'] + ' - ' + li['name_local']))
- # Redefine our choices, so we can add the translated language names and
- # sort the list by language name
- choices.append(self.fields['language'].choices[0])
- langs = self.fields['language'].choices[1:]
- langs.sort(key=lambda l: l[1].lower())
- for code, lang in langs:
- li = get_language_info(code)
- choices.append((code, lang + ' - ' + li['name_local']))
- self.fields['language'].choices = choices
-
- def save(self, commit=True):
- super(EnableURLInstForm, self).save(commit=False)
- if commit:
- # delete if exists
- if self.cleaned_data and self.cleaned_data['DELETE']:
- if self.instance.pk:
- return self.instance.delete()
- else:
- return None
- super(EnableURLInstForm, self).save()
- return self.instance
-
class BaseEnableURLInstFormSet(DynamicBaseModelFormSet):
model = EnableURLInst
@@ -612,12 +588,12 @@ def __init__(self, *args, **kwargs):
prefix=prefix,
delete=delete,
queryset=qs)
- # create a empty_inst_form
+ # create a empty_desc_form
if self.forms:
- self.empty_inst_form = self.forms[0].inst_formset.empty_form
+ self.empty_desc_form = self.forms[0].inst_formset.empty_form
else:
formset = self.EnableURLInstFormSet()
- self.empty_inst_form = formset.empty_form
+ self.empty_desc_form = formset.empty_form
def clean(self, **kwargs):
super(BaseEnableURLFormSet, self).clean(**kwargs)
View
2  ispdb/config/serializers.py
@@ -76,7 +76,7 @@ def xmlOneDotOne(data):
for inst in enableurl.instructions.all():
d = ET.SubElement(enable, "instruction")
d.attrib["lang"] = inst.language
- d.text = unicode(inst.instruction)
+ d.text = unicode(inst.description)
# DocURL
for docurl in data.docurl_set.all():
doc = ET.SubElement(emailProvider, "documentation")
View
2  ispdb/config/static/css/details.css
@@ -91,6 +91,6 @@
margin-top: 10px;
}
-.tab_desc, .tab_inst {
+.tab_desc {
margin-left: 10px;
}
View
2  ispdb/config/static/css/show_issue.css
@@ -63,6 +63,6 @@
float: right;
}
-.tab_desc, .tab_inst {
+.tab_desc {
margin-left: 10px;
}
View
2  ispdb/fixtures/issue_testdata.json
@@ -67,7 +67,7 @@
"model": "config.enableurlinst",
"fields": {
"enableurl": 1,
- "instruction": "test",
+ "description": "test",
"language": "en"
}
}
View
6 ispdb/fixtures/xml_testdata.json
@@ -90,7 +90,7 @@
"model": "config.enableurlinst",
"fields": {
"enableurl": 1,
- "instruction": "test",
+ "description": "test",
"language": "en"
}
},
@@ -107,7 +107,7 @@
"model": "config.enableurlinst",
"fields": {
"enableurl": 2,
- "instruction": "test",
+ "description": "test",
"language": "en"
}
},
@@ -116,7 +116,7 @@
"model": "config.enableurlinst",
"fields": {
"enableurl": 2,
- "instruction": "test2",
+ "description": "test2",
"language": "fr"
}
}
View
32 ispdb/templates/config/details.html
@@ -253,18 +253,10 @@
{% if docurls %}
<div id="docurl">
<h4>Documentation</h4>
- {% for docurl in docurls %}
- <table>
- <tr>
- <td>{{ docurl.url.label}}:</td><td>{{ docurl.url.value}}</td>
- </tr>
- </table>
- {% for desc in docurl.desc_formset %}
- <table class="tab_desc">
- <tr>
- <td>{{ desc.description.label }}:</td><td>{{ desc.description.value }}</td><td> {{ desc.language|data_verbose_field }}</td>
- </tr>
- </table>
+ {% for form in docurls %}
+ {% include "config/urls/url_list.html" %}
+ {% for desc_form in form.desc_formset %}
+ {% include "config/urls/desc_list.html" %}
{% endfor %}
{% endfor %}
</div>
@@ -273,18 +265,10 @@
{% if enableurls %}
<div id="enableurl">
<h4>Enable Instructions</h4>
- {% for enableurl in enableurls %}
- <table>
- <tr>
- <td>{{ enableurl.url.label}}:</td><td>{{ enableurl.url.value}}</td>
- </tr>
- </table>
- {% for inst in enableurl.inst_formset %}
- <table class="tab_inst">
- <tr>
- <td>{{ inst.instruction.label }}:</td><td>{{ inst.instruction.value }}</td><td> {{ inst.language|data_verbose_field }}</td>
- </tr>
- </table>
+ {% for form in enableurls %}
+ {% include "config/urls/url_list.html" %}
+ {% for desc_form in form.inst_formset %}
+ {% include "config/urls/desc_list.html" %}
{% endfor %}
{% endfor %}
</div>
View
191 ispdb/templates/config/enter_config.html
@@ -19,6 +19,11 @@
$("#{{docurl.desc_formset.prefix}}").hide();
{% endif %}
{% endfor %}
+ {% for enableurl in config_form.enableurl_formset %}
+ {% if enableurl.DELETE.value == "True" %}
+ $("#{{enableurl.inst_formset.prefix}}").hide();
+ {% endif %}
+ {% endfor %}
// add functions
function addRow(prefix, template_selector, tab_selector) {
@@ -65,22 +70,7 @@
$(this).text("Undo");
}
});
- $("#configform").on("click", "a.delete.desc", function(){
- var prefix = $(this).attr('value');
- var check = $('#id_'+prefix+'-DELETE');
- if (check.val() == "True"){
- check.val("False");
- $('#id_'+prefix+'-description').removeAttr("disabled");
- $('#id_'+prefix+'-language').removeAttr("disabled");
- $(this).text("Remove");
- } else {
- check.val("True");
- $('#id_'+prefix+'-description').attr("disabled", "disabled");
- $('#id_'+prefix+'-language').attr("disabled", "disabled");
- $(this).text("Undo");
- }
- });
- $("#configform").on("click", "a.delete.docurl", function(){
+ $("#configform").on("click", "a.delete.url", function(){
var prefix = $(this).attr('value');
var check = $('#id_'+prefix+'-DELETE');
if (check.val() == "True"){
@@ -95,36 +85,21 @@
$(this).text("Undo");
}
});
- $("#configform").on("click", "a.delete.inst", function(){
+ $("#configform").on("click", "a.delete.desc", function(){
var prefix = $(this).attr('value');
var check = $('#id_'+prefix+'-DELETE');
if (check.val() == "True"){
check.val("False");
- $('#id_'+prefix+'-instruction').removeAttr("disabled");
+ $('#id_'+prefix+'-description').removeAttr("disabled");
$('#id_'+prefix+'-language').removeAttr("disabled");
$(this).text("Remove");
} else {
check.val("True");
- $('#id_'+prefix+'-instruction').attr("disabled", "disabled");
+ $('#id_'+prefix+'-description').attr("disabled", "disabled");
$('#id_'+prefix+'-language').attr("disabled", "disabled");
$(this).text("Undo");
}
});
- $("#configform").on("click", "a.delete.enableurl", function(){
- var prefix = $(this).attr('value');
- var check = $('#id_'+prefix+'-DELETE');
- if (check.val() == "True"){
- check.val("False");
- $('#id_'+prefix+'-url').removeAttr("readonly");
- $(this).closest('tr').next().find('div').show();
- $(this).text("Remove");
- } else {
- check.val("True");
- $('#id_'+prefix+'-url').attr("readonly", "readonly");
- $(this).closest('tr').next().find('div').hide();
- $(this).text("Undo");
- }
- });
function showForm() {
$("#question").hide();
@@ -268,86 +243,46 @@
</tr>
{% endwith %}
</table>
+
<table style="display:none" id="docurl_template">
{% with config_form.docurl_formset.empty_form as form %}
- <tr>
- <th class="noborder">{{ form.url.label_tag }}:</th>
- <td class="noborder">
- {{ form.url }}
- {{ form.DELETE }}
- <a class="link delete docurl" value="{1}-{0}">Remove</a>
- </td>
- </tr>
+ {% include "config/urls/url_template_form.html" %}
+{% endwith %}
+</table>
+
+<table style="display:none" id="enableurl_template">
+{% with config_form.enableurl_formset.empty_form as form %}
+ {% include "config/urls/url_template_form.html" %}
{% endwith %}
</table>
+
<table style="display:none" id="desc_template">
{% with config_form.docurl_formset.empty_desc_form as form %}
- <tr>
- <th>{{ form.description.label_tag }}:</th>
- <td>{{ form.description }}</td>
- <td>
- {{ form.language }}
- {{ form.DELETE }}
- <a class="link delete desc" value="{1}-{0}">Remove</a>
- </td>
- </tr>
+ {% include "config/urls/desc_template_form.html" %}
+{% endwith %}
+</table>
+
+<table style="display:none" id="inst_template">
+{% with config_form.enableurl_formset.empty_desc_form as form %}
+ {% include "config/urls/desc_template_form.html" %}
{% endwith %}
</table>
+
<table style="display:none" id="desc_full_template">
{% with config_form.docurl_formset.empty_desc_form as form %}
<tr><td class="noborder"><td class="noborder"><div id="{1}"><table class="tab_descs">
<input type="hidden" name="{1}-TOTAL_FORMS" value="1" id="id_{1}-TOTAL_FORMS" /><input type="hidden" name="{1}-INITIAL_FORMS" value="0" id="{1}-INITIAL_FORMS" /><input type="hidden" name="{1}-MAX_NUM_FORMS" id="id_{1}-MAX_NUM_FORMS" />
- <tr>
- <th>{{ form.description.label_tag }}:</th>
- <td>{{ form.description }}</td>
- <td>
- {{ form.language }}
- {{ form.DELETE }}
- <a class="link delete desc" value="{1}-{0}">Remove</a>
- </td>
- </tr>
+ {% include "config/urls/desc_template_form.html" %}
<tr><td class="noborder"><a class="link add_desc" value="{1}">add another description</a></td></tr>
</table></div></td></td></tr>
{% endwith %}
</table>
-<table style="display:none" id="enableurl_template">
-{% with config_form.enableurl_formset.empty_form as form %}
- <tr>
- <th class="noborder">{{ form.url.label_tag }}:</th>
- <td class="noborder">
- {{ form.url }}
- {{ form.DELETE }}
- <a class="link delete enableurl" value="{1}-{0}">Remove</a>
- </td>
- </tr>
-{% endwith %}
-</table>
-<table style="display:none" id="inst_template">
-{% with config_form.enableurl_formset.empty_inst_form as form %}
- <tr>
- <th>{{ form.instruction.label_tag }}:</th>
- <td>{{ form.instruction }}</td>
- <td>
- {{ form.language }}
- {{ form.DELETE }}
- <a class="link delete inst" value="{1}-{0}">Remove</a>
- </td>
- </tr>
-{% endwith %}
-</table>
+
<table style="display:none" id="inst_full_template">
-{% with config_form.enableurl_formset.empty_inst_form as form %}
+{% with config_form.enableurl_formset.empty_desc_form as form %}
<tr><td class="noborder"><td class="noborder"><div id="{1}"><table class="tab_insts">
<input type="hidden" name="{1}-TOTAL_FORMS" value="1" id="id_{1}-TOTAL_FORMS" /><input type="hidden" name="{1}-INITIAL_FORMS" value="0" id="{1}-INITIAL_FORMS" /><input type="hidden" name="{1}-MAX_NUM_FORMS" id="id_{1}-MAX_NUM_FORMS" />
- <tr>
- <th>{{ form.instruction.label_tag }}:</th>
- <td>{{ form.instruction }}</td>
- <td>
- {{ form.language }}
- {{ form.DELETE }}
- <a class="link delete inst" value="{1}-{0}">Remove</a>
- </td>
- </tr>
+ {% include "config/urls/desc_template_form.html" %}
<tr><td><a class="link add_inst" value="{1}">add another instruction</a></td></tr>
</table></div></td></td></tr>
{% endwith %}
@@ -419,23 +354,9 @@ <h3 class="hidden" id="problem">There are missing or incorrect values in the for
<table id="tab_docurl">
{{ config_form.docurl_formset.management_form }}
- <tr><tdclass="noborder">{{ config_form.docurl_formset.non_form_errors }}</td></tr>
+ <tr><td class="noborder">{{ config_form.docurl_formset.non_form_errors }}</td></tr>
{% for form in config_form.docurl_formset %}
- <tr><td class="noborder">{{ form.non_field_errors }}</td></tr>
- {{ form.id }}
- <tr>
- <th class="noborder">{{ form.url.label_tag }}:</th>
- <td class="noborder">
- {{ form.url.errors }}
- {{ form.url }}
- {{ form.DELETE }}
- {% if form.DELETE.value == "True" %}
- <a class="link delete docurl" value="{{form.prefix}}">Undo</a>
- {% else %}
- <a class="link delete docurl" value="{{form.prefix}}">Remove</a>
- {% endif %}
- </td>
- </tr>
+ {% include "config/urls/url_form.html" %}
<tr><td class="noborder"><td class="noborder"><div id="{{form.desc_formset.prefix}}"><table class="tab_descs">
{{ form.desc_formset.management_form }}
<tr><td>{{ form.desc_formset.non_form_errors }}</td></tr>
@@ -443,20 +364,7 @@ <h3 class="hidden" id="problem">There are missing or incorrect values in the for
<tr><td>{{ error }}</td></tr>
{% endfor %}
{% for desc_form in form.desc_formset %}
- {{ desc_form.id }}
- <tr>
- <th>{{ desc_form.description.label_tag }}:</th>
- <td>{{ desc_form.description.errors }}{{ desc_form.description }}</td>
- <td>
- {{ desc_form.language.errors }}{{ desc_form.language }}
- {{ desc_form.DELETE }}
- {% if desc_form.DELETE.value == "True" %}
- <a class="link delete desc" value="{{desc_form.prefix}}">Undo</a>
- {% else %}
- <a class="link delete desc" value="{{desc_form.prefix}}">Remove</a>
- {% endif %}
- </td>
- </tr>
+ {% include "config/urls/desc_form.html" %}
{% endfor %}
<tr><td class="noborder"><a class="link add_desc" value="{{form.desc_formset.prefix}}">add another description</a></td></tr>
</table>
@@ -472,42 +380,15 @@ <h3 class="hidden" id="problem">There are missing or incorrect values in the for
{{ config_form.enableurl_formset.management_form }}
<tr><tdclass="noborder">{{ config_form.enableurl_formset.non_form_errors }}</td></tr>
{% for form in config_form.enableurl_formset %}
- <tr><td class="noborder">{{ form.non_field_errors }}</td></tr>
- {{ form.id }}
- <tr>
- <th class="noborder">{{ form.url.label_tag }}:</th>
- <td class="noborder">
- {{ form.url.errors }}
- {{ form.url }}
- {{ form.DELETE }}
- {% if form.DELETE.value == "True" %}
- <a class="link delete docurl" value="{{form.prefix}}">Undo</a>
- {% else %}
- <a class="link delete docurl" value="{{form.prefix}}">Remove</a>
- {% endif %}
- </td>
- </tr>
+ {% include "config/urls/url_form.html" %}
<tr><td class="noborder"><td class="noborder"><div id="{{form.inst_formset.prefix}}"><table class="tab_insts">
{{ form.inst_formset.management_form }}
<tr><td>{{ form.inst_formset.non_form_errors }}</td></tr>
{% for error in form.inst_formset.non_field_errors %}
<tr><td>{{ error }}</td></tr>
{% endfor %}
- {% for inst_form in form.inst_formset %}
- {{ inst_form.id }}
- <tr>
- <th>{{ inst_form.instruction.label_tag }}:</th>
- <td>{{ inst_form.instruction.errors }}{{ inst_form.instruction }}</td>
- <td>
- {{ inst_form.language.errors }}{{ inst_form.language }}
- {{ inst_form.DELETE }}
- {% if inst_form.DELETE.value == "True" %}
- <a class="link delete inst" value="{{inst_form.prefix}}">Undo</a>
- {% else %}
- <a class="link delete inst" value="{{inst_form.prefix}}">Remove</a>
- {% endif %}
- </td>
- </tr>
+ {% for desc_form in form.inst_formset %}
+ {% include "config/urls/desc_form.html" %}
{% endfor %}
<tr><td><a class="link add_inst" value="{{form.inst_formset.prefix}}">add another instruction</a></td></tr>
</table>
View
38 ispdb/templates/config/show_issue.html
@@ -133,40 +133,22 @@
<div id="docurl">
<h4>Documentation (only the suggested is shown)</h4>
- {% for docurl in new_docurl_formset %}
- <table>
- <tr>
- <td>{{ docurl.url.label}}:</td><td>{{ docurl.url.value}}</td>
- </tr>
- </table>
- <table class="tab_desc">
- {% for desc in docurl.desc_formset %}
- <tr>
- <td>{{ desc.description.label }}:</td><td>{{ desc.description.value }}</td><td> {{ desc.language|data_verbose_field }}</td>
- </tr>
+ {% for form in new_docurl_formset %}
+ {% include "config/urls/url_list.html" %}
+ {% for desc_form in form.desc_formset %}
+ {% include "config/urls/desc_list.html" %}
{% endfor %}
- </table>
- {% endfor %}
- </table>
+ {% endfor %}
</div>
<div id="enableurl">
<h4>Enable Instructions (only the suggested is shown)</h4>
- {% for enableurl in new_enableurl_formset %}
- <table>
- <tr>
- <td>{{ enableurl.url.label}}:</td><td>{{ enableurl.url.value}}</td>
- </tr>
- </table>
- <table class="tab_inst">
- {% for inst in enableurl.inst_formset %}
- <tr>
- <td>{{ inst.instruction.label }}:</td><td>{{ inst.instruction.value }}</td><td> {{ inst.language|data_verbose_field }}</td>
- </tr>
+ {% for form in new_enableurl_formset %}
+ {% include "config/urls/url_list.html" %}
+ {% for desc_form in form.inst_formset %}
+ {% include "config/urls/desc_list.html" %}
{% endfor %}
- </table>
- {% endfor %}
- </table>
+ {% endfor %}
</div>
</div>
View
14 ispdb/templates/config/urls/desc_form.html
@@ -0,0 +1,14 @@
+{{ desc_form.id }}
+<tr>
+ <th>{{ desc_form.description.label_tag }}:</th>
+ <td>{{ desc_form.description.errors }}{{ desc_form.description }}</td>
+ <td>
+ {{ desc_form.language.errors }}{{ desc_form.language }}
+ {{ desc_form.DELETE }}
+ {% if desc_form.DELETE.value == "True" %}
+ <a class="link delete desc" value="{{desc_form.prefix}}">Undo</a>
+ {% else %}
+ <a class="link delete desc" value="{{desc_form.prefix}}">Remove</a>
+ {% endif %}
+ </td>
+</tr>
View
6 ispdb/templates/config/urls/desc_list.html
@@ -0,0 +1,6 @@
+{% load custom_filters %}
+<table class="tab_desc">
+ <tr>
+ <td>{{ desc_form.description.label }}:</td><td>{{ desc_form.description.value }}</td><td> {{ desc_form.language|data_verbose_field }}</td>
+ </tr>
+</table>
View
9 ispdb/templates/config/urls/desc_template_form.html
@@ -0,0 +1,9 @@
+<tr>
+ <th>{{ form.description.label_tag }}:</th>
+ <td>{{ form.description }}</td>
+ <td>
+ {{ form.language }}
+ {{ form.DELETE }}
+ <a class="link delete desc" value="{1}-{0}">Remove</a>
+ </td>
+</tr>
View
15 ispdb/templates/config/urls/url_form.html
@@ -0,0 +1,15 @@
+<tr><td class="noborder">{{ form.non_field_errors }}</td></tr>
+{{ form.id }}
+<tr>
+ <th class="noborder">{{ form.url.label_tag }}:</th>
+ <td class="noborder">
+ {{ form.url.errors }}
+ {{ form.url }}
+ {{ form.DELETE }}
+ {% if form.DELETE.value == "True" %}
+ <a class="link delete url" value="{{form.prefix}}">Undo</a>
+ {% else %}
+ <a class="link delete url" value="{{form.prefix}}">Remove</a>
+ {% endif %}
+ </td>
+</tr>
View
5 ispdb/templates/config/urls/url_list.html
@@ -0,0 +1,5 @@
+<table>
+ <tr>
+ <td>{{ form.url.label}}:</td><td>{{ form.url.value}}</td>
+ </tr>
+</table>
View
8 ispdb/templates/config/urls/url_template_form.html
@@ -0,0 +1,8 @@
+<tr>
+ <th class="noborder">{{ form.url.label_tag }}:</th>
+ <td class="noborder">
+ {{ form.url }}
+ {{ form.DELETE }}
+ <a class="link delete url" value="{1}-{0}">Remove</a>
+ </td>
+</tr>
View
4 ispdb/tests/common.py
@@ -41,7 +41,7 @@ def asking_domain_form():
"inst_0-0-id": "",
"inst_0-0-DELETE": "False",
"inst_0-0-language": "en",
- "inst_0-0-instruction": "test"
+ "inst_0-0-description": "test"
}
@@ -92,5 +92,5 @@ def adding_domain_form():
"inst_0-0-id": "",
"inst_0-0-DELETE": "False",
"inst_0-0-language": "en",
- "inst_0-0-instruction": "test"
+ "inst_0-0-description": "test"
}
View
10 ispdb/tests/test_add.py
@@ -307,14 +307,14 @@ def test_add_one_deleted_enableurl(self):
domain_form["inst_1-0-id"] = ""
domain_form["inst_1-0-DELETE"] = "False"
domain_form["inst_1-0-language"] = "en"
- domain_form["inst_1-0-instruction"] = "test2"
+ domain_form["inst_1-0-description"] = "test2"
res = self.client.post(reverse("ispdb_add"), domain_form)
assert_equal(res.status_code, success_code)
model = models.EnableURL.objects.filter(url="http://test.com/")
assert_true(model)
model = models.EnableURL.objects.filter(url="http://test2.com/")
assert_false(model)
- model = models.EnableURLInst.objects.filter(instruction="test2")
+ model = models.EnableURLInst.objects.filter(description="test2")
assert_false(model)
def test_add_one_deleted_inst(self):
@@ -324,12 +324,12 @@ def test_add_one_deleted_inst(self):
domain_form["inst_0-1-id"] = ""
domain_form["inst_0-1-DELETE"] = "True"
domain_form["inst_0-1-language"] = "en"
- domain_form["inst_0-1-instruction"] = "test2"
+ domain_form["inst_0-1-description"] = "test2"
res = self.client.post(reverse("ispdb_add"), domain_form)
assert_equal(res.status_code, success_code)
- model = models.EnableURLInst.objects.filter(instruction="test")
+ model = models.EnableURLInst.objects.filter(description="test")
assert_true(model)
- model = models.EnableURLInst.objects.filter(instruction="test2")
+ model = models.EnableURLInst.objects.filter(description="test2")
assert_false(model)
View
8 ispdb/tests/test_edit.py
@@ -61,7 +61,7 @@ def test_edit_same_user(self):
form["enableurl-0-url"] = "http://test1.com/"
form["inst_0-INITIAL_FORMS"] = "1"
form["inst_0-0-id"] = "1"
- form["inst_0-0-instruction"] = "test1"
+ form["inst_0-0-description"] = "test1"
res = self.client.post(reverse("ispdb_edit",args=[1]),
form,
follow=True)
@@ -80,7 +80,7 @@ def test_edit_same_user(self):
enableurl = models.EnableURL.objects.get(pk=1)
assert_equal(enableurl.url, 'http://test1.com/')
inst = models.EnableURLInst.objects.get(pk=1)
- assert_equal(inst.instruction, 'test1')
+ assert_equal(inst.description, 'test1')
def test_edit_staff_user(self):
self.add_domain()
@@ -101,7 +101,7 @@ def test_edit_staff_user(self):
form["enableurl-0-url"] = "http://test1.com/"
form["inst_0-INITIAL_FORMS"] = "1"
form["inst_0-0-id"] = "1"
- form["inst_0-0-instruction"] = "test1"
+ form["inst_0-0-description"] = "test1"
res = self.client.post(reverse("ispdb_edit",args=[1]),
form,
follow=True)
@@ -120,7 +120,7 @@ def test_edit_staff_user(self):
enableurl = models.EnableURL.objects.get(pk=1)
assert_equal(enableurl.url, 'http://test1.com/')
inst = models.EnableURLInst.objects.get(pk=1)
- assert_equal(inst.instruction, 'test1')
+ assert_equal(inst.description, 'test1')
def test_edit_duplicated_names(self):
self.add_domain()
View
4 ispdb/tests/test_issue.py
@@ -39,7 +39,7 @@ def add_issue(self, updated_config=False, config_id=1):
form["enableurl-0-url"] = "http://test1.com/"
form["inst_0-INITIAL_FORMS"] = "1"
form["inst_0-0-id"] = "1"
- form["inst_0-0-instruction"] = "test1"
+ form["inst_0-0-description"] = "test1"
if updated_config:
form['show_form'] = 'True'
res = self.client.post(reverse("ispdb_report", args=[config_id]), form)
@@ -120,4 +120,4 @@ def test_merge_issue_superuser(self):
assert_equal(enableurl.url, 'http://test1.com/')
assert_equal(len(enableurl.instructions.all()), 1)
inst = enableurl.instructions.all()[0]
- assert_equal(inst.instruction, 'test1')
+ assert_equal(inst.description, 'test1')
View
2  ispdb/tests/test_view.py
@@ -63,7 +63,7 @@ def make_config(value):
"inst_0-0-id": "",
"inst_0-0-DELETE": "False",
"inst_0-0-language": "en",
- "inst_0-0-instruction": "test%s" % value
+ "inst_0-0-description": "test%s" % value
}
Please sign in to comment.
Something went wrong with that request. Please try again.