From: Łukasz Rekucki Date: Fri, 26 Mar 2010 19:07:26 +0000 (+0100) Subject: Cleanup of externals. X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/20be4d9d8dad31ecbda183f4b5c74c9d80799f72?ds=sidebyside;hp=--cc Cleanup of externals. --- 20be4d9d8dad31ecbda183f4b5c74c9d80799f72 diff --git a/.gitignore b/.gitignore index f11a79bab..1152ea7a0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,19 @@ localsettings.py dev.sqlite +dev.db # Python garbage *.pyc .coverage +pip-log.txt # Mac OS X garbage .DS_Store # Windows garbage thumbs.db + +# Eclipse +.project +.settings +.pydevproject diff --git a/README b/README index fa3064e1c..53d8fb60e 100644 --- a/README +++ b/README @@ -26,6 +26,8 @@ Just execute this commands: Używany kod open-source ======================= +Zewnętrzny: + django ------ - Źródła: [djangoproject.com](http://www.djangoproject.com/) @@ -33,19 +35,36 @@ django - Licencja: [BSD License](http://code.djangoproject.com/browser/django/trunk/LICENSE) - Typ: framework -django-chunks -------------- - - Źródła: [Google Code](http://code.google.com/p/django-chunks/) - - Autorzy: Clint Ecker - - Licencja: [New BSD License](http://www.opensource.org/licenses/bsd-license.php) - - Typ: biblioteka (aplikacja django) - django-pagination ----------------- - Źródła: [Google Code](http://code.google.com/p/django-pagination/) - Autorzy: James Tauber , leidel@gmail.com - Licencja: [New BSD License](http://www.opensource.org/licenses/bsd-license.php) - Typ: biblioteka (aplikacja django) + +Django South +----- +- Źródła: [aercode.org](http://south.aeracode.org/) +- Autorzy: Andrew Godwin , Andy McCurdy +- Licencja: [Apache License 2.0](http://www.opensource.org/licenses/apache2.0.php) +- Typ: biblioteka (aplikacja django) + +lxml +---- + - Å»ródła: [codespeak.net](http://codespeak.net/lxml/index.html#download) + - Autorzy: [wielu autorów](http://codespeak.net/lxml/credits.html) + - Licencja: [BSD License](http://codespeak.net/lxml/index.html#license) + - Typ: biblioteka + +feedparser +---------- + - Źródła: [Google Code](http://code.google.com/p/feedparser/) + - Autorzy: Mark Pilgrim + - Licencja: [MIT License](http://www.opensource.org/licenses/mit-license.php) + - Typ: biblioteka + + +Wewnętrzny (w źródłach): django-compress --------------- @@ -53,7 +72,14 @@ django-compress - Autorzy: Andreas Pelme - Licencja: [MIT License](http://www.opensource.org/licenses/mit-license.php) - Typ: biblioteka (aplikacja django) - + + django-chunks +------------- + - Źródła: [Google Code](http://code.google.com/p/django-chunks/) + - Autorzy: Clint Ecker + - Licencja: [New BSD License](http://www.opensource.org/licenses/bsd-license.php) + - Typ: biblioteka (aplikacja django) + django-newtagging ----------------- - Źródła: [BitBucket](http://www.bitbucket.org/zuber/django-newtagging/) @@ -61,20 +87,10 @@ django-newtagging - Licencja: [MIT License](http://www.opensource.org/licenses/mit-license.php) - Typ: biblioteka (aplikacja django) - Nota: Aplikacja wzorowana na [django-tagging](http://code.google.com/p/django-tagging/), która jest również wydana na licencji [MIT](http://www.opensource.org/licenses/mit-license.php) Około połowa kodu jest dzielona. - -south ------ -- Źródła: [aercode.org](http://south.aeracode.org/) -- Autorzy: Andrew Godwin , Andy McCurdy -- Licencja: [Apache License 2.0](http://www.opensource.org/licenses/apache2.0.php) -- Typ: biblioteka (aplikacja django) - -feedparser ----------- - - Źródła: [Google Code](http://code.google.com/p/feedparser/) - - Autorzy: Mark Pilgrim - - Licencja: [MIT License](http://www.opensource.org/licenses/mit-license.php) - - Typ: biblioteka + +django-piston (0.2.3rc) +------------------------ + - http://bitbucket.org/jespern/django-piston/wiki/Home markupstring ------------ @@ -82,12 +98,4 @@ markupstring - Autorzy: Thomas Hinkle - Licencja: [MIT License](http://code.activestate.com/help/terms/) - Typ: biblioteka - - Nota: Zmienione przez Marka Stępniowskiego tak, żeby akceptowało ciągi znaków Unicode - -lxml ----- - - Å»ródła: [codespeak.net](http://codespeak.net/lxml/index.html#download) - - Autorzy: [wielu autorów](http://codespeak.net/lxml/credits.html) - - Licencja: [BSD License](http://codespeak.net/lxml/index.html#license) - - Typ: biblioteka - + - Nota: Zmienione przez Marka Stępniowskiego tak, żeby akceptowało ciągi znaków Unicode \ No newline at end of file diff --git a/apps/catalogue/models.py b/apps/catalogue/models.py index 2f4e7fe06..a9e39de01 100644 --- a/apps/catalogue/models.py +++ b/apps/catalogue/models.py @@ -108,7 +108,6 @@ class Book(models.Model): objects = models.Manager() tagged = managers.ModelTaggedItemManager(Tag) tags = managers.TagDescriptor(Tag) - @property def name(self): diff --git a/apps/newtagging/models.py b/apps/newtagging/models.py index e121994c7..e1e92b67e 100644 --- a/apps/newtagging/models.py +++ b/apps/newtagging/models.py @@ -1,8 +1,11 @@ """ Models and managers for generic tagging. """ + # Python 2.3 compatibility -if not hasattr(__builtins__, 'set'): +try: + set +except NameError: from sets import Set as set from django.contrib.contenttypes import generic diff --git a/apps/pagination/__init__.py b/apps/pagination/__init__.py deleted file mode 100644 index 8b1378917..000000000 --- a/apps/pagination/__init__.py +++ /dev/null @@ -1 +0,0 @@ - diff --git a/apps/pagination/middleware.py b/apps/pagination/middleware.py deleted file mode 100644 index 0bab76712..000000000 --- a/apps/pagination/middleware.py +++ /dev/null @@ -1,10 +0,0 @@ -class PaginationMiddleware(object): - """ - Inserts a variable representing the current page onto the request object if - it exists in either **GET** or **POST** portions of the request. - """ - def process_request(self, request): - try: - request.page = int(request.REQUEST['page']) - except (KeyError, ValueError): - request.page = 1 \ No newline at end of file diff --git a/apps/pagination/models.py b/apps/pagination/models.py deleted file mode 100644 index 8b1378917..000000000 --- a/apps/pagination/models.py +++ /dev/null @@ -1 +0,0 @@ - diff --git a/apps/pagination/templates/pagination/pagination.html b/apps/pagination/templates/pagination/pagination.html deleted file mode 100644 index 3799314e4..000000000 --- a/apps/pagination/templates/pagination/pagination.html +++ /dev/null @@ -1,25 +0,0 @@ -{% if is_paginated %} - -{% endif %} diff --git a/apps/pagination/templatetags/__init__.py b/apps/pagination/templatetags/__init__.py deleted file mode 100644 index 8b1378917..000000000 --- a/apps/pagination/templatetags/__init__.py +++ /dev/null @@ -1 +0,0 @@ - diff --git a/apps/pagination/templatetags/pagination_tags.py b/apps/pagination/templatetags/pagination_tags.py deleted file mode 100644 index 4908421ea..000000000 --- a/apps/pagination/templatetags/pagination_tags.py +++ /dev/null @@ -1,202 +0,0 @@ -try: - set -except NameError: - from sets import Set as set -from django import template -from django.db.models.query import QuerySet -from django.core.paginator import Paginator, QuerySetPaginator, InvalidPage - -register = template.Library() - -DEFAULT_PAGINATION = 20 -DEFAULT_WINDOW = 4 -DEFAULT_ORPHANS = 0 - -def do_autopaginate(parser, token): - """ - Splits the arguments to the autopaginate tag and formats them correctly. - """ - split = token.split_contents() - if len(split) == 2: - return AutoPaginateNode(split[1]) - elif len(split) == 3: - try: - paginate_by = int(split[2]) - except ValueError: - raise template.TemplateSyntaxError(u'Got %s, but expected integer.' % split[2]) - return AutoPaginateNode(split[1], paginate_by=paginate_by) - elif len(split) == 4: - try: - paginate_by = int(split[2]) - except ValueError: - raise template.TemplateSyntaxError(u'Got %s, but expected integer.' % split[2]) - try: - orphans = int(split[3]) - except ValueError: - raise template.TemplateSyntaxError(u'Got %s, but expected integer.' % split[3]) - return AutoPaginateNode(split[1], paginate_by=paginate_by, orphans=orphans) - else: - raise template.TemplateSyntaxError('%r tag takes one required argument and one optional argument' % split[0]) - -class AutoPaginateNode(template.Node): - """ - Emits the required objects to allow for Digg-style pagination. - - First, it looks in the current context for the variable specified. This - should be either a QuerySet or a list. - - 1. If it is a QuerySet, this ``AutoPaginateNode`` will emit a - ``QuerySetPaginator`` and the current page object into the context names - ``paginator`` and ``page_obj``, respectively. - - 2. If it is a list, this ``AutoPaginateNode`` will emit a simple - ``Paginator`` and the current page object into the context names - ``paginator`` and ``page_obj``, respectively. - - It will then replace the variable specified with only the objects for the - current page. - - .. note:: - - It is recommended to use *{% paginate %}* after using the autopaginate - tag. If you choose not to use *{% paginate %}*, make sure to display the - list of availabale pages, or else the application may seem to be buggy. - """ - def __init__(self, queryset_var, paginate_by=DEFAULT_PAGINATION, orphans=DEFAULT_ORPHANS): - self.queryset_var = template.Variable(queryset_var) - self.paginate_by = paginate_by - self.orphans = orphans - - def render(self, context): - key = self.queryset_var.var - value = self.queryset_var.resolve(context) - if issubclass(value.__class__, QuerySet): - model = value.model - paginator_class = QuerySetPaginator - else: - value = list(value) - try: - model = value[0].__class__ - except IndexError: - return u'' - paginator_class = Paginator - paginator = paginator_class(value, self.paginate_by, self.orphans) - try: - page_obj = paginator.page(context['request'].page) - except InvalidPage: - # context[key] = [] - # context['invalid_page'] = True - # return u'' - from django.http import Http404 - raise Http404 - context[key] = page_obj.object_list - context['paginator'] = paginator - context['page_obj'] = page_obj - return u'' - -def paginate(context, window=DEFAULT_WINDOW): - """ - Renders the ``pagination/pagination.html`` template, resulting in a - Digg-like display of the available pages, given the current page. If there - are too many pages to be displayed before and after the current page, then - elipses will be used to indicate the undisplayed gap between page numbers. - - Requires one argument, ``context``, which should be a dictionary-like data - structure and must contain the following keys: - - ``paginator`` - A ``Paginator`` or ``QuerySetPaginator`` object. - - ``page_obj`` - This should be the result of calling the page method on the - aforementioned ``Paginator`` or ``QuerySetPaginator`` object, given - the current page. - - This same ``context`` dictionary-like data structure may also include: - - ``getvars`` - A dictionary of all of the **GET** parameters in the current request. - This is useful to maintain certain types of state, even when requesting - a different page. - """ - try: - paginator = context['paginator'] - page_obj = context['page_obj'] - page_range = paginator.page_range - # First and last are simply the first *n* pages and the last *n* pages, - # where *n* is the current window size. - first = set(page_range[:window]) - last = set(page_range[-window:]) - # Now we look around our current page, making sure that we don't wrap - # around. - current_start = page_obj.number-1-window - if current_start < 0: - current_start = 0 - current_end = page_obj.number-1+window - if current_end < 0: - current_end = 0 - current = set(page_range[current_start:current_end]) - pages = [] - # If there's no overlap between the first set of pages and the current - # set of pages, then there's a possible need for elusion. - if len(first.intersection(current)) == 0: - first_list = sorted(list(first)) - second_list = sorted(list(current)) - pages.extend(first_list) - diff = second_list[0] - first_list[-1] - # If there is a gap of two, between the last page of the first - # set and the first page of the current set, then we're missing a - # page. - if diff == 2: - pages.append(second_list[0] - 1) - # If the difference is just one, then there's nothing to be done, - # as the pages need no elusion and are correct. - elif diff == 1: - pass - # Otherwise, there's a bigger gap which needs to be signaled for - # elusion, by pushing a None value to the page list. - else: - pages.append(None) - pages.extend(second_list) - else: - pages.extend(sorted(list(first.union(current)))) - # If there's no overlap between the current set of pages and the last - # set of pages, then there's a possible need for elusion. - if len(current.intersection(last)) == 0: - second_list = sorted(list(last)) - diff = second_list[0] - pages[-1] - # If there is a gap of two, between the last page of the current - # set and the first page of the last set, then we're missing a - # page. - if diff == 2: - pages.append(second_list[0] - 1) - # If the difference is just one, then there's nothing to be done, - # as the pages need no elusion and are correct. - elif diff == 1: - pass - # Otherwise, there's a bigger gap which needs to be signaled for - # elusion, by pushing a None value to the page list. - else: - pages.append(None) - pages.extend(second_list) - else: - pages.extend(sorted(list(last.difference(current)))) - to_return = { - 'pages': pages, - 'page_obj': page_obj, - 'paginator': paginator, - 'is_paginated': paginator.count > paginator.per_page, - } - if 'request' in context: - getvars = context['request'].GET.copy() - if 'page' in getvars: - del getvars['page'] - if len(getvars.keys()) > 0: - to_return['getvars'] = "&%s" % getvars.urlencode() - else: - to_return['getvars'] = '' - return to_return - except KeyError: - return {} -register.inclusion_tag('pagination/pagination.html', takes_context=True)(paginate) -register.tag('autopaginate', do_autopaginate) \ No newline at end of file diff --git a/apps/pagination/tests.py b/apps/pagination/tests.py deleted file mode 100644 index 837e55cfe..000000000 --- a/apps/pagination/tests.py +++ /dev/null @@ -1,52 +0,0 @@ -""" ->>> from django.core.paginator import Paginator ->>> from pagination.templatetags.pagination_tags import paginate ->>> from django.template import Template, Context - ->>> p = Paginator(range(15), 2) ->>> paginate({'paginator': p, 'page_obj': p.page(1)})['pages'] -[1, 2, 3, 4, 5, 6, 7, 8] - ->>> p = Paginator(range(17), 2) ->>> paginate({'paginator': p, 'page_obj': p.page(1)})['pages'] -[1, 2, 3, 4, 5, 6, 7, 8, 9] - ->>> p = Paginator(range(19), 2) ->>> paginate({'paginator': p, 'page_obj': p.page(1)})['pages'] -[1, 2, 3, 4, None, 7, 8, 9, 10] - ->>> p = Paginator(range(21), 2) ->>> paginate({'paginator': p, 'page_obj': p.page(1)})['pages'] -[1, 2, 3, 4, None, 8, 9, 10, 11] - -# Testing orphans ->>> p = Paginator(range(5), 2, 1) ->>> paginate({'paginator': p, 'page_obj': p.page(1)})['pages'] -[1, 2] - ->>> p = Paginator(range(21), 2, 1) ->>> paginate({'paginator': p, 'page_obj': p.page(1)})['pages'] -[1, 2, 3, 4, None, 7, 8, 9, 10] - ->>> t = Template("{% load pagination_tags %}{% autopaginate var 2 %}{% paginate %}") - -# WARNING: Please, please nobody read this portion of the code! ->>> class GetProxy(object): -... def __iter__(self): yield self.__dict__.__iter__ -... def copy(self): return self -... def urlencode(self): return u'' -... def keys(self): return [] ->>> class RequestProxy(object): -... page = 1 -... GET = GetProxy() ->>> -# ENDWARNING - ->>> t.render(Context({'var': range(21), 'request': RequestProxy()})) -u'\\n -{% endblock %} +{% endblock %} \ No newline at end of file