Permalink
Browse files

work on cydhcp templates, purge pdb finally

  • Loading branch information...
1 parent 82cdd6b commit 42615d0a0b5d652cdf69d3ffca1f4f3ca47d7aeb @ngokevin committed Dec 11, 2012
Showing with 140 additions and 313 deletions.
  1. +10 −0 cyder/base/helpers.py
  2. +24 −20 cyder/base/mixins.py
  3. +8 −8 cyder/base/templates/base/includes/pagination.html
  4. +1 −1 cyder/base/templates/base/includes/sidebars.html
  5. +6 −12 cyder/base/templates/base/list.html
  6. +3 −4 cyder/base/views.py
  7. +0 −1 cyder/core/search/compile_search.py
  8. +0 −1 cyder/core/search/compiler/compiler.py
  9. +0 −1 cyder/core/search/compiler/lexer.py
  10. +0 −1 cyder/core/search/compiler/parser.py
  11. +0 −1 cyder/core/search/compiler/tokenizer.py
  12. +0 −1 cyder/core/search/parser.py
  13. +0 −1 cyder/core/search/search.py
  14. +3 −30 cyder/core/search/views.py
  15. +0 −1 cyder/cydhcp/build/subnet.py
  16. +0 −1 cyder/cydhcp/build/views.py
  17. +0 −30 cyder/cydhcp/bulk_change/views.py
  18. +0 −1 cyder/cydhcp/interface/static_intr/tests/A_tests.py
  19. +0 −1 cyder/cydhcp/interface/static_intr/tests/CNAME_tests.py
  20. +0 −1 cyder/cydhcp/interface/static_intr/tests/PTR_tests.py
  21. +0 −1 cyder/cydhcp/interface/static_intr/tests/aux_attrs.py
  22. +0 −1 cyder/cydhcp/interface/static_intr/tests/basic.py
  23. +0 −1 cyder/cydhcp/interface/static_intr/tests/deletetion.py
  24. +0 −1 cyder/cydhcp/interface/static_intr/tests/ipv6_basic.py
  25. +0 −1 cyder/cydhcp/interface/static_intr/tests/system_integration.py
  26. +0 −1 cyder/cydhcp/keyvalue/base_option.py
  27. +0 −1 cyder/cydhcp/keyvalue/models.py
  28. +0 −1 cyder/cydhcp/keyvalue/utils.py
  29. +0 −1 cyder/cydhcp/lib/tests/free_ip.py
  30. +0 −1 cyder/cydhcp/lib/tests/intr_from_domain.py
  31. +0 −1 cyder/cydhcp/lib/tests/intr_from_range.py
  32. +0 −1 cyder/cydhcp/lib/utils.py
  33. +0 −1 cyder/cydhcp/network/forms.py
  34. +0 −1 cyder/cydhcp/network/models.py
  35. +16 −25 cyder/cydhcp/network/network_wizard.py
  36. +0 −1 cyder/cydhcp/network/tests.py
  37. +1 −1 cyder/cydhcp/network/urls.py
  38. +0 −1 cyder/cydhcp/network/utils.py
  39. +8 −25 cyder/cydhcp/network/views.py
  40. +0 −1 cyder/cydhcp/populate.py
  41. +0 −1 cyder/cydhcp/range/forms.py
  42. +0 −1 cyder/cydhcp/range/models.py
  43. +0 −1 cyder/cydhcp/range/tests/ipv4_tests.py
  44. +0 −1 cyder/cydhcp/range/tests/ipv6_tests.py
  45. +1 −1 cyder/cydhcp/range/urls.py
  46. +14 −15 cyder/cydhcp/range/views.py
  47. +1 −1 cyder/cydhcp/site/urls.py
  48. +0 −1 cyder/cydhcp/site/utils.py
  49. +3 −12 cyder/cydhcp/site/views.py
  50. +4 −4 cyder/cydhcp/templates/cydhcp/includes/cydhcp_sidebar.html
  51. +0 −1 cyder/cydhcp/utils.py
  52. +3 −8 cyder/cydhcp/views.py
  53. +0 −1 cyder/cydhcp/vlan/models.py
  54. +1 −1 cyder/cydhcp/vlan/urls.py
  55. +5 −14 cyder/cydhcp/vlan/views.py
  56. +0 −1 cyder/cydns/api/tests/basic.py
  57. +0 −1 cyder/cydns/api/tests/kv.py
  58. +0 −1 cyder/cydns/api/tests/ptr.py
  59. +0 −1 cyder/cydns/api/v1/api.py
  60. +0 −1 cyder/cydns/cybind/generators/bind_domain_generator.py
  61. +0 −1 cyder/cydns/cybind/generators/bind_reverse_domain_generator.py
  62. +0 −1 cyder/cydns/domain/tests/auto_create.py
  63. +0 −1 cyder/cydns/domain/tests/auto_delete.py
  64. +0 −1 cyder/cydns/domain/tests/auto_update.py
  65. +0 −1 cyder/cydns/domain/tests/basic.py
  66. +0 −1 cyder/cydns/domain/tests/full_name.py
  67. +0 −1 cyder/cydns/domain/tests/test_reverse.py
  68. +0 −1 cyder/cydns/nameserver/tests/test_models.py
  69. +0 −1 cyder/cydns/ptr/models.py
  70. +0 −1 cyder/cydns/search_utils.py
  71. +0 −1 cyder/cydns/super_views.py
  72. +1 −1 cyder/cydns/templates/cydns/cydns_record_view.html
  73. +0 −1 cyder/cydns/validation.py
  74. +0 −1 cyder/cydns/view/tests.py
  75. +3 −3 cyder/cydns/views.py
  76. +0 −1 cyder/dnsutils/build_nics.py
  77. +0 −1 cyder/dnsutils/inventory_build.py
  78. +0 −1 cyder/dnsutils/management/commands/buildnetworks.py
  79. +0 −1 cyder/dnsutils/management/commands/buildzone.py
  80. +0 −1 cyder/dnsutils/management/commands/buildzone2.py
  81. +0 −1 cyder/dnsutils/management/commands/buildzone3.py
  82. +0 −19 cyder/dnsutils/network_build.py
  83. +0 −1 cyder/dnsutils/svn_build.py
  84. +0 −1 cyder/dnsutils/tests/include_forward.py
  85. +0 −1 cyder/dnsutils/tests/include_reverse.py
  86. +0 −1 cyder/dnsutils/tests/soa.py
  87. +0 −1 cyder/dnsutils/utils.py
  88. +0 −1 cyder/dnsutils/zone_migrate.py
  89. +24 −12 media/css/sticky_footer.css
View
@@ -1,5 +1,6 @@
# Jingo helpers (Jinja2 custom filters)
import json
+import string
from jingo import register
@@ -23,6 +24,15 @@ def humanized_class_name(obj, *args, **kwargs):
return humanized
@register.filter
+def humanized_model_name(model_name, *args, **kwargs):
+ """
+ Capitalize and add spaces to underscored db table names.
+ """
+ model_name.replace('_', ' ')
+ return string.join([word[0].upper() + word[1:]
+ for word in model_name.split()])
+
+@register.filter
def prettify_record_type(record_type, *args, **kwargs):
"""
Turns all-lowercase record type string to all caps or splits into
View
@@ -9,39 +9,43 @@ class uses the ``_meta.db_table`` instance variable of an object to
calculate URLs. Because of this, you must use the app label of your
class when declaring urls in your urls.py.
"""
- def get_detail_url(self):
+ @classmethod
+ def get_list_url(cls):
"""
- Return the detail url of an object.
+ Return the 'list' url of an object. Class method since don't
+ need specific instance of object.
"""
- return reverse(self._meta.db_table.replace('-', '_') + '-detail',
- args=[self.pk])
+ return reverse(cls._meta.db_table)
- def get_list_url(self):
+ @classmethod
+ def get_create_url(cls):
"""
- Return the list url of an object.
+ Return the create url of the type of object (to be posted to).
"""
- return reverse(self._meta.db_table.replace('-', '_') + '-list')
+ return cls.get_list_url() + '-create'
def get_update_url(self):
"""
- Return the update url of an object.
+ Return the update url of an object (to be posted to). Not class method
+ because object pk needed.
"""
- return reverse(self._meta.db_table.replace('-', '_') + '-update',
- args=[self.pk])
+ return reverse(self._meta.db_table + '-update', args=[self.pk])
def get_delete_url(self):
"""
- Return the delete url of an object.
+ Return the delete url of an object (to be posted to).
+ """
+ return reverse(self._meta.db_table + '-delete', args=[self.pk])
+
+ def get_detail_url(self):
+ """
+ Return the detail url of an object.
"""
- return reverse(self._meta.db_table.replace('-', '_') + '-delete',
- args=[self.pk])
+ return reverse(self._meta.db_table + '-detail', args=[self.pk])
- def get_create_url(self):
+ def details(self):
"""
- Return the create url of the type of object.
+ Return base details with generic postback URL for editable tables.
"""
- try:
- return reverse(self._meta.db_table.replace('-', '_') + '-create',
- args=[self.pk])
- except:
- return reverse(self._meta.db_table.replace('-', '_') + '-create')
+ return {'url': reverse(self._meta.db_table + '-table-update',
+ args=[self.pk])}
@@ -1,21 +1,21 @@
<div class="pagination">
<ul>
<li><a href="?page=1">First</a></li>
- {% if object_list.has_previous() %}
+ {% if page_obj.has_previous() %}
<li>
- <a href="?page={{ object_list.previous_page_number() }}">Prev</a>
+ <a href="?page={{ page_obj.previous_page_number() }}">Prev</a>
</li>
{% else %}
<li class="disabled">
<a href="#">Prev</a></li>
{% endif %}
</li>
- {% for page in range(1, object_list.paginator.num_pages + 1) %}
+ {% for page in range(1, page_obj.paginator.num_pages + 1) %}
{# Divide range of pages into 10 so it doesn't fill up screen.
So 100-page-paginator would show 0...10...20...30 #}
- {% if object_list.paginator.num_pages / 10 == 0 or object_list.paginator.num_pages < 10 %}
- {% if object_list.number == page %}
+ {% if page_obj.paginator.num_pages / 10 == 0 or page_obj.paginator.num_pages < 10 %}
+ {% if page_obj.number == page %}
<li class="active">
<a href="#">{{ page }}</a>
</li>
@@ -27,14 +27,14 @@
{% endif %}
{% endfor %}
- {% if object_list.has_next() %}
+ {% if page_obj.has_next() %}
<li>
- <a href="?page={{ object_list.next_page_number() }}">Next</a></li>
+ <a href="?page={{ page_obj.next_page_number() }}">Next</a></li>
{% else %}
<li class="disabled">
<a href="#">Next</a></li>
{% endif %}
</li>
- <li><a href="?page={{ object_list.paginator.num_pages }}">Last</a></li>
+ <li><a href="?page={{ page_obj.paginator.num_pages }}">Last</a></li>
</ul>
</div>
@@ -1,7 +1,7 @@
{% macro render_sidebar(request, urls_names) -%}
{% for named_url, name in urls_names %}
<span class="nav-item">
- <a class="nav-link {{ 'selected' if url(named_url) in request.path }}" href="{{ url(named_url) }}">{{ name }}</a>
+ <a class="nav-link {{ 'selected' if url(named_url) == request.path }}" href="{{ url(named_url) }}">{{ name }}</a>
</span>
{% endfor %}
{%- endmacro %}
@@ -1,25 +1,19 @@
{% extends "base/base.html" %}
{% from "base/tables.html" import render_table %}
-{% block title %}
- {% if object_list %}
- {{ object_list[0]|humanized_class_name + 's'}}
- {% endif %}
-{% endblock %}
-
-{% block header %}
- {% if object_list %}
- {{ object_list[0]|humanized_class_name + 's'}}
- {% endif %}
-{% endblock %}
+{% block title %}{{ model_name|humanized_model_name + 's'}}{% endblock %}
+{% block header %}{{ model_name|humanized_model_name + 's'}}{% endblock %}
{% block action_bar %}
+ <a class="btn" href="{{ Model.get_create_url() }}">
+ Create {{ model_name|humanized_model_name }}
+ </a>
{% endblock %}
{% block content %}
{% block form %}{% endblock %}
- {% if object_list and object_list.paginator %}
+ {% if page_obj %}
{% include "base/includes/pagination.html" %}
{% endif %}
View
@@ -17,13 +17,12 @@ class BaseListView(ListView):
"""
template_name = 'list.html'
extra_context = None
- paginate_by = 200
+ paginate_by = 50
def get_context_data(self, **kwargs):
context = super(ListView, self).get_context_data(**kwargs)
- context['form_title'] = "{0} Details".format(
- self.form_class.Meta.model.__name__
- )
+ context['Model'] = self.model
+ context['model_name'] = self.model._meta.db_table
# Extra_context takes precedence over original values in context.
try:
@@ -10,7 +10,6 @@
from cyder.cydhcp.vlan.models import Vlan
from cyder.cydhcp.utils import IPFilterSet
-import pdb
import ipaddr
@@ -16,7 +16,6 @@
from parser import Parser
from utils import *
from itertools import izip
-import pdb
class Compiler(object):
@@ -1,5 +1,4 @@
import re
-import pdb
class Lexer(object):
@@ -1,5 +1,4 @@
import re
-import pdb
from copy import deepcopy
from tokenizer import Tokenizer
from utils import *
@@ -15,7 +15,6 @@
from lexer import Lexer
import re
-import pdb
PR_UOP = 1
PR_LPAREN = 2
@@ -1,5 +1,4 @@
import re
-import pdb
"""
<stmt> -> <term> <stmt>
@@ -9,7 +9,6 @@
from cyder.cydhcp.site.models import Site
from cyder.cydhcp.vlan.models import Vlan
-import pdb
import ipaddr
View
@@ -1,37 +1,9 @@
-from django.db.models import Q
-from django.core.exceptions import ObjectDoesNotExist, ValidationError
-from django.shortcuts import get_object_or_404, redirect
from django.shortcuts import render
-from django.contrib import messages
-from django.forms.util import ErrorList
from django.http import HttpResponse
-from cyder.core.system.models import System
-
-from cyder.core.views import CoreDeleteView, CoreCreateView
-from cyder.cydhcp.interface.static_intr.models import StaticInterface
-from cyder.cydhcp.interface.static_intr.models import StaticIntrKeyValue
-from cyder.cydhcp.interface.static_intr.forms import StaticInterfaceForm
-from cyder.cydhcp.interface.static_intr.forms import FullStaticInterfaceForm
-from cyder.cydhcp.interface.static_intr.forms import StaticInterfaceQuickForm
-from cyder.cydhcp.interface.static_intr.forms import CombineForm
-from cyder.cydhcp.keyvalue.utils import get_attrs, update_attrs, get_aa, get_docstrings
-from cyder.cydhcp.keyvalue.utils import get_docstrings, dict_to_kv
-from cyder.cydhcp.range.models import Range
-from cyder.cydhcp.network.utils import calc_parent_str
-
-from cyder.cydns.domain.models import Domain
-from cyder.cydns.address_record.models import AddressRecord
-from cyder.cydns.ptr.models import PTR
-
from cyder.core.search.parser import parse
from cyder.core.search.search import compile_search
-import re
-import ipaddr
-import operator
-import simplejson as json
-
def search(request):
search = request.GET.get('search', None)
@@ -41,8 +13,9 @@ def search(request):
dos_terms = ['10', 'com', 'mozilla.com', 'mozilla', 'network:10/8',
'network:10.0.0.0/8']
if search in dos_terms:
- return HttpResponse('Denial of Service attack prevented. The search '
- 'term \'{0}\' is too general'.format(search))
+ return HttpResponse(
+ 'Denial of Service attack prevented. The search '
+ 'term \'{0}\' is too general'.format(search))
query = parse(search)
print '----------------------'
print query
@@ -1,7 +1,6 @@
from cyder.cydhcp.network.models import Network
from cyder.cydhcp.interface.static_intr.models import StaticInterface
-import pdb
# This doesn't work for IPv6
@@ -3,7 +3,6 @@
from django.shortcuts import render_to_response, get_object_or_404
from django.http import HttpResponse
-import pdb
def build_network(request, network_pk):
@@ -1,39 +1,9 @@
-from django.db.models import Q
-from django.core.exceptions import ObjectDoesNotExist, ValidationError
-from django.shortcuts import get_object_or_404, redirect, render_to_response
from django.shortcuts import render
-from django.contrib import messages
-from django.forms.util import ErrorList
from django.http import HttpResponse
-from cyder.core.system.models import System
-
-from cyder.cydhcp.interface.static_intr.models import StaticInterface
-from cyder.cydhcp.interface.static_intr.models import StaticIntrKeyValue
-from cyder.cydhcp.interface.static_intr.forms import StaticInterfaceForm
-from cyder.cydhcp.interface.static_intr.forms import FullStaticInterfaceForm
-from cyder.cydhcp.interface.static_intr.forms import StaticInterfaceQuickForm
-from cyder.cydhcp.interface.static_intr.forms import CombineForm
-from cyder.cydhcp.keyvalue.utils import get_attrs, update_attrs, get_aa, get_docstrings
-from cyder.cydhcp.keyvalue.utils import get_docstrings, dict_to_kv
-from cyder.cydhcp.views import CydhcpDeleteView, CydhcpCreateView
-from cyder.cydhcp.range.models import Range
-from cyder.cydhcp.network.utils import calc_parent_str
-
-from cyder.cydns.domain.models import Domain
-from cyder.cydns.address_record.models import AddressRecord
-from cyder.cydns.ptr.models import PTR
-
from cyder.core.search.parser import parse
from cyder.core.search.search import compile_search
-import pdb
-import re
-import ipaddr
-import operator
-import simplejson as json
-
-
from jinja2 import Environment, PackageLoader
env = Environment(loader=PackageLoader('cydhcp.bulk_change', 'templates'))
@@ -9,7 +9,6 @@
from cyder.cydns.ip.utils import ip_to_domain_name, nibbilize
-import pdb
class AStaticRegTests(TestCase):
@@ -9,7 +9,6 @@
from cyder.cydns.ip.utils import ip_to_domain_name, nibbilize
-import pdb
class CNAMEStaticRegTests(TestCase):
@@ -8,7 +8,6 @@
from cyder.cydns.ip.utils import ip_to_domain_name, nibbilize
-import pdb
class PTRStaticRegTests(TestCase):
@@ -10,7 +10,6 @@
from cyder.cydns.ip.utils import ip_to_domain_name, nibbilize
-import pdb
class AuxAttrTests(TestCase):
@@ -10,7 +10,6 @@
from cyder.cydns.ip.utils import ip_to_domain_name, nibbilize
-import pdb
class StaticInterTests(TestCase):
@@ -10,7 +10,6 @@
from cyder.cydns.ip.utils import ip_to_domain_name, nibbilize
-import pdb
class DeleteStaticInterTests(TestCase):
Oops, something went wrong.

0 comments on commit 42615d0

Please sign in to comment.