Browse files

Added some more staff to the subscription models and created the admi…

…n for the subscriptions. Adjusted urls.py in order to suppot the automaic redirection to /admin
  • Loading branch information...
1 parent 5445273 commit 0d1135b758930a05a9c02601a57ef266bd626204 Aaron Riedener committed Jul 11, 2011
Showing with 78 additions and 15 deletions.
  1. +44 −0 subscriptions/admin.py
  2. +33 −14 subscriptions/models.py
  3. +1 −1 urls.py
View
44 subscriptions/admin.py
@@ -0,0 +1,44 @@
+# -*- coding: utf-8 -*-
+import os
+from django import forms
+from django.core.urlresolvers import reverse
+from datetime import date
+from crm.models import *
+from django.utils.translation import ugettext as _
+from django.contrib import admin
+from django.http import HttpResponse
+from django.http import HttpResponseRedirect
+from django.core.servers.basehttp import FileWrapper
+
+class AdminSubscriptionEvent(admin.TabularInline):
+ model = SubscriptionEvent
+ extra = 1
+ classes = ('collapse-open',)
+ fieldsets = (
+ ('Basics', {
+ 'fields': ('eventdate', 'event',)
+ }),
+ )
+ allow_add = True
+
+class OptionSubscription(admin.ModelAdmin):
+ list_display = ('id', 'customer','subscriptiontype' , 'startdate', 'cancelingdate', 'staff', 'lastmodification', 'lastmodifiedby')
+ list_display_links = ('id', )
+ list_filter = ('customer', 'startdate', 'staff', 'defaultcurrency')
+ ordering = ('id', 'defaultcustomer', 'defaultcurrency')
+ search_fields = ('id','contract', 'defaultcurrency__description')
+ fieldsets = (
+ (_('Basics'), {
+ 'fields': ('description', 'defaultcustomer', 'defaultSupplier', 'defaultcurrency')
+ }),
+ )
+ inlines = [SubscriptionEvent, ContractPhoneAddress, ContractEmailAddress, InlineQuote, InlineInvoice, InlinePurchaseOrder]
+
+ def save_model(self, request, obj, form, change):
+ if (change == True):
+ obj.lastmodifiedby = request.user
+ else:
+ obj.lastmodifiedby = request.user
+ obj.staff = request.user
+ obj.save()
+ actions = ['createContract', 'createInvoice', 'createQuote']
View
47 subscriptions/models.py
@@ -1,12 +1,16 @@
from django.db import models
+from filebrowser.fields import FileBrowseField
+from const.events import *
+import crm import models
-class Subscription
- customer = customer
- stopdate = datefield
- stopdate = datefield
- staff = userfield
- lastmodified = datefield
- lastmodifiedby = datefield
+class Subscription(models.Model):
+ customer = models.ForeignKey('Customer', verbose_name= _('Customer'))
+ subscriptiontype = models.ForeignKey('SubscriptionType', verbose_name=_('Subscription Type'))
+ startdate = models.DateField(verbose_name = _("Start Date"), blank=True, null=True)
+ staff = models.ForeignKey('auth.User', limit_choices_to={'is_staff': True}, blank=True, verbose_name = _("Staff"), related_name="db_relpostaff", null=True)
+ cancelingdate = models.DateField(verbose_name = _("Canceling Date"), blank=True, null=True)
+ lastmodification = models.DateTimeField(verbose_name = _("Last modified"), auto_now_add=True)
+ lastmodifiedby = models.ForeignKey('auth.User', limit_choices_to={'is_staff': True}, verbose_name = _("Last modified by"), related_name="db_polstmodified")
def __unicode__(self):
return self.title
@@ -17,13 +21,28 @@ class Meta:
verbose_name = _('Subscription')
verbose_name_plural = _('Subscriptions')
-class Subscriptiontype
- kuendbarkeit = integerfield
- contractduration = integerfield
- vertragsverlaengerungbeinnichtkuendigung = integerfield
- vertragsintervall = integerfield
- zahlungsintervall = integerfield
- vertragsdokumente = Filebrowserfield
+class SubscriptionEvent(models.Model):
+ subscriptions = models.ForeignKey('Subscription', verbose_name= _('Subscription'))
+ eventdate = models.DateField(verbose_name = _("Event Date"), blank=True, null=True)
+ event = models.CharField(max_length=1, choices=SUBSCRITIONEVENTS, verbose_name=_('Event'))
+
+ def __unicode__(self):
+ return self.event
+
+ class Meta:
+ app_label = "subscriptions"
+ #app_label_koalix = _("Subscriptions")
+ verbose_name = _('Subscription Event')
+ verbose_name_plural = _('Subscription Events')
+
+
+class SubscriptionType(models.Model):
+ cancelationPeriod = models.IntegerField(verbose_name = _("Cancelation Period (months)"), blank=True, null=True)
+ automaticContractExtension = models.IntegerField(verbose_name = _("Automatic Contract Extension (months)"), blank=True, null=True)
+ automaticContractExtensionReminder = models.IntegerField(verbose_name = _("Automatic Contract Extensoin Reminder (days)"), blank=True, null=True)
+ minimumDuration = models.IntegerField(verbose_name = _("Minimum Contract Duration"), blank=True, null=True)
+ paymentIntervall = models.IntegerField(verbose_name = _("Payment Intervall (days)"), blank=True, null=True)
+ contractDocument = FileBrowseField(verbose_name=_("Contract Documents"), blank=True, null=True, max_length=200)
class Meta:
app_label = "subscriptions"
View
2 urls.py
@@ -6,7 +6,7 @@
urlpatterns = patterns('',
(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': '/var/www/koalixcrm/media'}),
- (r'^$', 'django.views.generic.simple.redirect_to', {'url': '/'}),
+ (r'^$', 'django.views.generic.simple.redirect_to', {'url': '/admin'}),
(r'^admin_tools/', include('admin_tools.urls')),
(r'^grappelli/', include('grappelli.urls')),
(r'^admin/filebrowser/', include('filebrowser.urls')),

0 comments on commit 0d1135b

Please sign in to comment.