Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan8 committed Feb 8, 2013
1 parent f815459 commit 72297c9
Show file tree
Hide file tree
Showing 21 changed files with 1,620 additions and 4 deletions.
47 changes: 43 additions & 4 deletions .gitignore
@@ -1,4 +1,43 @@
*.log
*.pot
*.pyc
local_settings.py
*.py[cod]

# C extensions
*.so

# Packages
*.egg
*.egg-info
dist
build
eggs
parts
bin
var
sdist
develop-eggs
.installed.cfg
lib
lib64

# Installer logs
pip-log.txt

# Unit test / coverage reports
.coverage
.tox
nosetests.xml

# Translations
*.mo

# Mr Developer
.mr.developer.cfg
.project
.pydevproject
.idea

# dev db
*.sqlite
*.sqlite3

# sphinx
docs/_build
Empty file added INSTALL
Empty file.
21 changes: 21 additions & 0 deletions LICENSE
@@ -0,0 +1,21 @@
django-ctt
==========

Copyright (C) Hiddendata

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 change: 1 addition & 0 deletions ctt/__init__.py
@@ -0,0 +1 @@
from core import register
35 changes: 35 additions & 0 deletions ctt/core.py
@@ -0,0 +1,35 @@
#!/usr/bin/env python
#-*- coding: utf-8 -*-
#vim: set ts=4 sw=4 et fdm=marker : */
from django.db import models


class TreePathModel(models.Model):
# ancestor = models.ForeignKey('Node', related_name='tpa')
# descendant = models.ForeignKey('Node', related_name='tpd')
path_len = models.IntegerField()

class Meta:
unique_together = ('ancestor', 'descendant')
abstract = True

def __unicode__(self):
return '%s -> %s (%d)' % (self.ancestor, self.descendant, self.path_len)


def register(cls):
"""
generuje TreePathModel dla podanego modelu
:param cls:
:return:
"""
tpcls = type(cls.__name__ + 'TreePath',
(TreePathModel,),
{'__module__': cls.__module__})
ancestor_field = models.ForeignKey(cls, related_name='tpa')
descendant_field = models.ForeignKey(cls, related_name='tpd')
ancestor_field.contribute_to_class(tpcls, 'ancestor')
descendant_field.contribute_to_class(tpcls, 'descendant')
cls._tpm = tpcls
cls._cls = cls
return tpcls
20 changes: 20 additions & 0 deletions ctt/decorators.py
@@ -0,0 +1,20 @@
#!/usr/bin/env python
#-*- coding: utf-8 -*-
#vim: set ts=4 sw=4 et fdm=marker : */
import functools


def filtered_qs(func):
"""
#TODO: zrobić, obsługę funkcji z argumentami
:param func:
:return:
"""

@functools.wraps(func)
def wrapped(self, *args, **kwargs):
ret_qs = func(self)
return ret_qs.filter(*args, **kwargs)

return wrapped

3 changes: 3 additions & 0 deletions ctt/managers.py
@@ -0,0 +1,3 @@
#!/usr/bin/env python
#-*- coding: utf-8 -*-
#vim: set ts=4 sw=4 et fdm=marker : */

0 comments on commit 72297c9

Please sign in to comment.