Example #1
0
    self.children = qs.select_related('content_type', 'user')[:self.limit]
    if not len(self.children):
        self.pre_content = _('No recent actions.')
    self._initialized = True


SiteAdmin.fieldsets = fieldsets = ((None, {
    'fields': ['domain', 'name', 'site_cutting', 'price_field_slugs', 'obl'] +
    ['country_' + lang[0] for lang in settings.LANGUAGES] +
    ['company_' + lang[0] for lang in settings.LANGUAGES]
}), )
# add shortning to Site model. For auto selecting site-dependent information
Site.add_to_class(
    'site_cutting',
    EavSlugField(_('Site cutting'),
                 help_text=_("Short unique site identifier."),
                 max_length=14,
                 unique=True))
Site.add_to_class(
    'price_field_slugs',
    CharField(
        _('Price field attrs'),
        help_text=
        _("Attributes of price fields for this site, separated with comma-space."
          ),
        max_length=200))
Site.add_to_class(
    'company',
    CharField(
        _('Site company'),
        help_text=_(
Example #2
0
    target = GenericForeignKey("target_content_type", "target_object_id")
    name = models.CharField(
        max_length=32,
        db_index=True,
        help_text="A name used to identify the relation. It must follow the \
naming convention a-underscore-b, eg. blog_galleries. Once set it is \
typically never changed.")

    class Meta:
        unique_together = (("source_content_type", "source_object_id",
                            "target_content_type", "target_object_id",
                            "name"), )


def set_managers(sender, **kwargs):
    """
    Make sure all classes have the appropriate managers.
    """
    cls = sender

    if issubclass(cls, ModelBase):
        cls.add_to_class("permitted", PermittedManager())


signals.class_prepared.connect(set_managers)

# Add natural_key to Django's Site model and manager
Site.add_to_class("natural_key", lambda self: (self.domain, self.name))
SiteManager.get_by_natural_key = lambda self, domain, name: self.get(
    domain=domain, name=name)
Example #3
0
from django.db import models
from django.contrib.sites.models import Site
from primer.db.models import UUIDField

# Monky Patch Site Model
Site.add_to_class('uuid', UUIDField())
Site.add_to_class('created', models.DateTimeField(auto_now_add=True, editable = False, blank = True, null = True))
Site.add_to_class('modified', models.DateTimeField(auto_now=True, blank = True, null = True))
Example #4
0
from django.db import models
from django.contrib.sites.models import Site

Site.add_to_class('fb_page_url', models.URLField(max_length=200, verbose_name=u'Facebook page url', null=True, blank=True))
Site.add_to_class('page_title', models.CharField(max_length=50, verbose_name=u'Page title'))
Site.add_to_class('page_subtitle', models.CharField(max_length=50, verbose_name=u'Page subtitle', null=True, blank=True))
Site.add_to_class('billboard_image', models.ImageField(max_length=100, upload_to='billboard_images/', verbose_name=u'Billboard image', null=True, blank=True))



Example #5
0
from django.db import models
from django.contrib.sites.models import Site
from primer.db.models import UUIDField

# Monky Patch Site Model
Site.add_to_class('uuid', UUIDField())
Site.add_to_class(
    'created',
    models.DateTimeField(auto_now_add=True,
                         editable=False,
                         blank=True,
                         null=True))
Site.add_to_class('modified',
                  models.DateTimeField(auto_now=True, blank=True, null=True))
Example #6
0
File: models.py Project: wd5/1-jmbo
    class Meta:
        unique_together = ((
            'source_content_type', 'source_object_id', 'target_content_type',
            'target_object_id', 'name'
        ),)


def set_managers(sender, **kwargs):
    """
    Make sure all classes have the appropriate managers.
    """
    cls = sender

    if issubclass(cls, ModelBase):
        cls.add_to_class('permitted', PermittedManager())

signals.class_prepared.connect(set_managers)


# add natural_key to Django's Site model and manager
Site.add_to_class('natural_key', lambda self: (self.domain, self.name))
SiteManager.get_by_natural_key = lambda self, domain, name: self.get(domain=domain, name=name)

# enable voting for ModelBase, but specify a different total name
# so ModelBase's vote_total method is not overwritten
secretballot.enable_voting_on(
    ModelBase,
    total_name="secretballot_added_vote_total"
)
Example #7
0
from django.db.models import CharField,BooleanField
from django.contrib.sites.models import Site
from django.conf import settings



Site.add_to_class('code', CharField(max_length=64,unique=True))
Site.add_to_class('api', CharField(max_length=255))

Site.add_to_class('key', CharField(max_length=255))
Site.add_to_class('secret', CharField(max_length=255))

Site.add_to_class("type",CharField(max_length=64,choices = settings.WEBSITE_TYPE))
Site.add_to_class('is_active', BooleanField())
Example #8
0
from django.db import models
from django.contrib.sites.models import Site

Site.add_to_class(
    'fb_page_url',
    models.URLField(max_length=200,
                    verbose_name=u'Facebook page url',
                    null=True,
                    blank=True))
Site.add_to_class('page_title',
                  models.CharField(max_length=50, verbose_name=u'Page title'))
Site.add_to_class(
    'page_subtitle',
    models.CharField(max_length=50,
                     verbose_name=u'Page subtitle',
                     null=True,
                     blank=True))
Site.add_to_class(
    'billboard_image',
    models.ImageField(max_length=100,
                      upload_to='billboard_images/',
                      verbose_name=u'Billboard image',
                      null=True,
                      blank=True))
Example #9
0
	"""
	Automatically creates a default user profile for newly created users.
	We don't set the site here, as we cannot know which would be appropriate.
	"""
	if created:
		UserProfile.objects.create(user=instance)
post_save.connect(create_user_profile, sender=User)



"""
Add a new field to the django.contrib.sites.Site which indicates whether the
respective site represents a normal shop (is_multishop = False) or a new
'multishop' (is_multishop = True). Default is False.
"""
Site.add_to_class('is_multishop', models.BooleanField(default=False))


#
# Order changes and additions.
#


def belongs_to_multishop(self):
	"""Returns True when the order belongs to a multishop."""
	return self.site.is_multishop
Order.add_to_class('belongs_to_multishop', belongs_to_multishop)

@property
def is_multishoporder(self):
	"""Property alias for belongs_to_multishop"""
Example #10
0
class Enlaces(models.Model):
    descripcion = models.CharField(max_length=30,
                                   verbose_name=_(u'descripción'))
    url = models.URLField()
    ubicacion = models.BooleanField(verbose_name=_(u'ubicación'), choices=MB)

    def __unicode__(self):
        return unicode("%s" % self.descripcion)

    class Meta:
        verbose_name = _(u'Enlaces')
        verbose_name_plural = _(u'Enlaces')


Site.add_to_class('titulo',
                  models.CharField(max_length=20, verbose_name=_(u'título')))
Site.add_to_class(
    'subtitulo', models.CharField(max_length=20, verbose_name=_(u'subtítulo')))
Site.add_to_class('informacion',
                  models.TextField(verbose_name=_(u'información')))
Site.add_to_class(
    'logo',
    ImageWithThumbsField(upload_to='configuracion/files',
                         sizes=((120, 100), ),
                         verbose_name=_(u'logo')))
Site.add_to_class(
    'banner',
    ImageWithThumbsField(upload_to='configuracion/files',
                         sizes=((160, 600), ),
                         verbose_name=_(u'banner 160x600')))
Example #11
0
    if self.exclude_list:
        qs = qs.exclude(get_qset(self.exclude_list))

    self.children = qs.select_related('content_type', 'user')[:self.limit]
    if not len(self.children):
        self.pre_content = _('No recent actions.')
    self._initialized = True

SiteAdmin.fieldsets=fieldsets = (
        (None, {
            'fields': ['domain', 'name', 'site_cutting','price_field_slugs', 'obl'] + ['country_'+lang[0] for lang in settings.LANGUAGES] + ['company_'+lang[0] for lang in settings.LANGUAGES]
        }),

        )
# add shortning to Site model. For auto selecting site-dependent information
Site.add_to_class('site_cutting', EavSlugField(_('Site cutting'),help_text=_("Short unique site identifier."), max_length=14, unique=True))
Site.add_to_class('price_field_slugs', CharField(_('Price field attrs'),help_text=_("Attributes of price fields for this site, separated with comma-space."), max_length=200))
Site.add_to_class('company', CharField(_('Site company'),help_text=_('Site company will show in header country-company selection'),max_length=70))
Site.add_to_class('country', CharField(_('Site country'),help_text=_('Site country will show in header country-company selection'),max_length=70))
Site.add_to_class('obl', ManyToManyField(CustomRegion, verbose_name=_("Choose if you want some areas to have their own domains"), blank=True))


#add cache info for pages
#from modifier import help_functions
#help_functions.cache_start_values()


#prints time of start
#TODO put in log?
from time import gmtime, strftime
print 'start time: ', strftime("%Y-%m-%d %H:%M:%S", gmtime())