Skip to content

Commit

Permalink
Restructure our python module. A lot.
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelm committed Feb 14, 2015
1 parent cf18f3e commit 077413f
Show file tree
Hide file tree
Showing 117 changed files with 193 additions and 163 deletions.
8 changes: 4 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "src/pretixbase/static/bootstrap"]
path = src/pretixbase/static/bootstrap
[submodule "src/pretix/base/static/bootstrap"]
path = src/pretix/base/static/bootstrap
url = https://github.com/twbs/bootstrap.git
[submodule "src/pretixbase/static/fontawesome"]
path = src/pretixbase/static/fontawesome
[submodule "src/pretix/base/static/fontawesome"]
path = src/pretix/base/static/fontawesome
url = https://github.com/FortAwesome/Font-Awesome.git
4 changes: 2 additions & 2 deletions doc/development/api/plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ example, taken from the time restriction module (see next chapter) as a template
name = 'pretixplugins.timerestriction'
verbose_name = _("Time restriction")

class TixlPluginMeta:
class PretixPluginMeta:
type = PluginType.RESTRICTION
name = _("Restriciton by time")
author = _("the pretix team")
Expand All @@ -70,7 +70,7 @@ example, taken from the time restriction module (see next chapter) as a template
default_app_config = 'pretixplugins.timerestriction.TimeRestrictionApp'

.. IMPORTANT::
You have to implement a ``TixlPluginMeta`` class like in the example to make your
You have to implement a ``PretixPluginMeta`` class like in the example to make your
plugin available to the users.

.. _signal dispatcher: https://docs.djangoproject.com/en/1.7/topics/signals/
Expand Down
16 changes: 8 additions & 8 deletions doc/development/concepts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,26 @@ The components

The project pretix is split into several components. The main three of them are:

**pretixbase**
Tixlbase is the foundation below all other components. It is primarily
**pretix.base**
Pretixbase is the foundation below all other components. It is primarily
responsible for the data structures and database communication. It also hosts
several utilities which are used by multiple other components.

**pretixcontrol**
Tixlcontrol is the web-based backend software which allows organizers to
**pretix.control**
Pretixcontrol is the web-based backend software which allows organizers to
create and manage their events, items, orders and tickets.

**pretixpresale**
Tixlpresale is the ticket-shop itself, containing all the parts visible to the
**pretix.presale**
Pretixpresale is the ticket-shop itself, containing all the parts visible to the
end user.

Users and events
^^^^^^^^^^^^^^^^

Tixl is all about **events**, which are defined as something happening somewhere.
Pretix is all about **events**, which are defined as something happening somewhere.
Every Event is managed by the **organizer**, an abstract entity running the event.

Tixl is used by **users**. We want to enable global users who can just login into
Pretix is used by **users**. We want to enable global users who can just login into
pretix and buy tickets for as many events as they like but at the same time it
should be possible to create some kind of local user to have a temporary account
just to buy tickets for one single event.
Expand Down
4 changes: 2 additions & 2 deletions doc/development/goals.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Development goals
=================

Tixl is a web software handling presale of event tickets.
Pretix is a web software handling presale of event tickets.

Technical goals
---------------
Expand All @@ -19,7 +19,7 @@ Feature goals

* One pretix software installation has to cope with multiple events by multiple organizers
* There is no code access necessary to create a new event
* Tixl is abstract in many ways to adopt to as much events as possible.
*Tixe is abstract in many ways to adopt to as much events as possible.
* Tickets are only an instance of an abstract model called items, such that the system can also sell e.g. merchandise
* An abstract concept of restriction is used to restrict the selling of tickets, for example by date, by number or by user permissions.
Expand Down
40 changes: 22 additions & 18 deletions doc/development/structure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ Python source code
All the source code lives in ``src/``, which has several subdirectories.

pretix/
This directory contains the basic Django settings and URL routing.
This directory contains nearly all source code.

pretixbase/
This is the django app containing all the models and methods which are
essential to all of pretix's features.
base/
This is the django app containing all the models and methods which are
essential to all of pretix's features.

pretixcontrol/
This is the django app containing the frontend for organizers.
control/
This is the django app containing the frontend for organizers.

pretixpresale/
This is the django app containing the frontend for users buying tickets.
presale/
This is the django app containing the frontend for users buying tickets.

helpers/
Helpers contain a very few modules providing workarounds for low-level flaws in
Django or installed 3rd-party packages, like a filter to combine the ``lessc``
preprocessor with ``django-compressor``'s URL rewriting.
helpers/
Helpers contain a very few modules providing workarounds for low-level flaws in
Django or installed 3rd-party packages, like a filter to combine the ``lessc``
preprocessor with ``django-compressor``'s URL rewriting.

Language files
--------------
Expand All @@ -37,21 +37,25 @@ LESS source code
We use less as a preprocessor for CSS. Our own less code is built in the same
step as Bootstrap and FontAwesome, so their mixins etc. are fully available.

pretixcontrol
pretixcontrol has two main LESS files, ``pretixcontrol/static/pretixcontrol/less/main.less`` and
``pretixcontrol/static/pretixcontrol/less/auth.less``, importing everything else.
pretix.control
pretixcontrol has two main LESS files, ``pretix/control/static/pretixcontrol/less/main.less`` and
``pretix/control/static/pretixcontrol/less/auth.less``, importing everything else.

pretix.presale
pretixpresale has one main LESS files, ``pretix/control/static/pretix/presale/less/main.less``,
importing everything else.

3rd-party assets
^^^^^^^^^^^^^^^^

Bootstrap
Bootstrap lives as a git submodule at ``pretixbase/static/bootstrap/``
Bootstrap lives as a git submodule at ``pretix/base/static/bootstrap/``

Font Awesome
Font Awesome lives as a git submodule at ``pretixbase/static/fontawesome/``
Font Awesome lives as a git submodule at ``pretix/base/static/fontawesome/``

jQuery
jQuery lives as a single JavaScript file in ``pretixbase/static/jquery/js/``
jQuery lives as a single JavaScript file in ``pretix/base/static/jquery/js/``

jQuery plugin: Django formsets
Our own modified version of `django-formset-js`_ is available as an independent
Expand Down
2 changes: 1 addition & 1 deletion src/.coveragerc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[run]
source = pretixbase,pretixcontrol,pretixpresale,pretixplugins
source = pretix
omit = */migrations/*,*/urls.py,*/tests/*,*/testdummy/*,*/admin.py

[report]
Expand Down
8 changes: 8 additions & 0 deletions src/pretix/base/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.apps import AppConfig


class PretixBaseConfig(AppConfig):
name = 'pretix.base'
label = 'pretixbase'

default_app_config = 'pretix.base.PretixBaseConfig'
12 changes: 6 additions & 6 deletions src/pretixbase/admin.py → src/pretix/base/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
from django.utils.translation import ugettext as _
from django import forms

from pretixbase.models import (
from pretix.base.models import (
User, Organizer, OrganizerPermission, Event, EventPermission,
Property, PropertyValue, Item, ItemVariation, ItemCategory
)


class TixlUserCreationForm(forms.ModelForm):
class PretixUserCreationForm(forms.ModelForm):

"""
A form that creates a user, with no privileges, from the given username and
Expand Down Expand Up @@ -39,14 +39,14 @@ def clean_password2(self):
return password2

def save(self, commit=True):
user = super(TixlUserCreationForm, self).save(commit=False)
user = super(PretixUserCreationForm, self).save(commit=False)
user.set_password(self.cleaned_data["password1"])
if commit:
user.save()
return user


class TixlUserAdmin(UserAdmin):
class PretixUserAdmin(UserAdmin):

fieldsets = (
(None, {'fields': ('identifier', 'event', 'username', 'password')}),
Expand All @@ -59,7 +59,7 @@ class TixlUserAdmin(UserAdmin):
search_fields = ('identifier', 'username', 'givenname', 'familyname', 'email')
ordering = ('identifier',)
list_filter = ('is_staff', 'is_active', 'groups')
add_form = TixlUserCreationForm
add_form = PretixUserCreationForm


class OrganizerPermissionInline(admin.TabularInline):
Expand Down Expand Up @@ -126,7 +126,7 @@ class ItemAdmin(admin.ModelAdmin):
search_fields = ('name', 'event', 'category', 'short_description')


admin.site.register(User, TixlUserAdmin)
admin.site.register(User, PretixUserAdmin)
admin.site.register(Organizer, OrganizerAdmin)
admin.site.register(Event, EventAdmin)
admin.site.register(Property, PropertyAdmin)
Expand Down
2 changes: 1 addition & 1 deletion src/pretixbase/cache.py → src/pretix/base/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from django.core.cache import caches

from pretixbase.models import Event
from pretix.base.models import Event


class EventRelatedCache:
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from django.conf import settings
import django.db.models.deletion
import django.utils.timezone
import pretixbase.models
import pretix.base.models


class Migration(migrations.Migration):
Expand Down Expand Up @@ -322,7 +322,8 @@ class Migration(migrations.Migration):
('items', versions.models.VersionedManyToManyField(blank=True, related_name='quotas', to='pretixbase.Item', verbose_name='Item')),
('lock_cache', models.ManyToManyField(blank=True, to='pretixbase.CartPosition')),
('order_cache', models.ManyToManyField(blank=True, to='pretixbase.OrderPosition')),
('variations', pretixbase.models.VariationsField(blank=True, related_name='quotas', to='pretixbase.ItemVariation', verbose_name='Variations')),
('variations', pretix.base.models.VariationsField(blank=True, related_name='quotas',
to='pretixbase.ItemVariation', verbose_name='Variations')),
],
options={
'verbose_name_plural': 'Quotas',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from __future__ import unicode_literals

from django.db import models, migrations
import pretixbase.models
import pretix.base.models
import versions.models


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from django.db import models, migrations
import versions.models
import pretixbase.models
import pretix.base.models


class Migration(migrations.Migration):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.utils.timezone import utc
import versions.models
import datetime
import pretixbase.models
import pretix.base.models


class Migration(migrations.Migration):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from __future__ import unicode_literals

from django.db import models, migrations
import pretixbase.models
import pretix.base.models
import versions.models


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from __future__ import unicode_literals

from django.db import models, migrations
import pretixbase.models
import pretix.base.models
import versions.models


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from django.db import models, migrations
import versions.models
import pretixbase.models
import pretix.base.models


class Migration(migrations.Migration):
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions src/pretixbase/models.py → src/pretix/base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,8 @@ def get_date_to_display(self) -> str:
"DATETIME_FORMAT" if self.show_times else "DATE_FORMAT"
)

def get_cache(self) -> "pretixbase.cache.EventRelatedCache":
from pretixbase.cache import EventRelatedCache
def get_cache(self) -> "pretix.base.cache.EventRelatedCache":
from pretix.base.cache import EventRelatedCache
return EventRelatedCache(self)


Expand Down Expand Up @@ -929,7 +929,7 @@ class VariationsField(VersionedManyToManyField):
"""

def formfield(self, **kwargs):
from pretixcontrol.views.forms import VariationsField as FVariationsField
from pretix.control.views.forms import VariationsField as FVariationsField
from django.db.models.fields.related import RelatedField
defaults = {
'form_class': FVariationsField,
Expand Down
6 changes: 3 additions & 3 deletions src/pretixbase/plugins.py → src/pretix/base/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ class PluginType(Enum):

def get_all_plugins() -> "List[class]":
"""
Returns the TixlPluginMeta classes of all plugins found in the installed Django apps.
Returns the PretixPluginMeta classes of all plugins found in the installed Django apps.
"""
plugins = []
for app in apps.get_app_configs():
if hasattr(app, 'TixlPluginMeta'):
meta = app.TixlPluginMeta
if hasattr(app, 'PretixPluginMeta'):
meta = app.PretixPluginMeta
meta.module = app.name
plugins.append(meta)
return plugins
2 changes: 1 addition & 1 deletion src/pretixbase/signals.py → src/pretix/base/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def send(self, sender, **named):
Send signal from sender to all connected receivers that belong to
plugins enabled for the given Event.
sender is required to be an instance of ``pretixbase.models.Event``.
sender is required to be an instance of ``pretix.base.models.Event``.
"""
assert isinstance(sender, Event)

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from django.core.cache import cache as django_cache
from django.utils.timezone import now

from pretixbase.models import Event, Organizer
from pretix.base.models import Event, Organizer


class CacheTest(TestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from django.utils.timezone import now
from django.conf import settings

from pretixbase.models import Event, Organizer, User
from pretix.base.models import Event, Organizer, User


class LocaleDeterminationTest(TestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
from django.test import TestCase
from django.utils.timezone import now

from pretixbase.models import (
from pretix.base.models import (
Event, Organizer, Item, ItemVariation,
Property, PropertyValue, User, Quota,
Order, OrderPosition, CartPosition
)
from pretixbase.types import VariationDict
from pretix.base.types import VariationDict


class ItemVariationsTest(TestCase):
Expand Down

0 comments on commit 077413f

Please sign in to comment.