Skip to content

Commit

Permalink
Merge branch 'branch-1.4'
Browse files Browse the repository at this point in the history
Conflicts:
	accounts/tests.py
	core/context_processors.py
	locale/en/LC_MESSAGES/django.mo
	locale/en/LC_MESSAGES/django.po
	locale/fr/LC_MESSAGES/django.mo
	locale/fr/LC_MESSAGES/django.po
  • Loading branch information
fgaudin committed Dec 2, 2011
2 parents c5e69c1 + 34c37a0 commit c3e64d3
Show file tree
Hide file tree
Showing 13 changed files with 463 additions and 190 deletions.
55 changes: 54 additions & 1 deletion accounts/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
INVOICE_STATE_SENT, InvoiceRowAmountError, PAYMENT_TYPE_CHECK, \
PAYMENT_TYPE_CASH, Expense, INVOICE_STATE_PAID
from contact.models import Country, Contact, CONTACT_TYPE_PERSON
from autoentrepreneur.models import UserProfile
from autoentrepreneur.models import UserProfile, \
AUTOENTREPRENEUR_REGISTER_RSEIRL
from django.contrib.webdesign import lorem_ipsum

class ExpensePermissionTest(TestCase):
Expand Down Expand Up @@ -907,6 +908,58 @@ def testDownloadPdf(self):
self.assertEquals(hashlib.md5("\n".join(invariant_content)).hexdigest(),
"8d6ca232060a96f8ad6855bdce59dc2c")

def testDownloadPdfWithRegistrationNumber(self):
"""
Tests non-regression on pdf
"""
profile = User.objects.get(pk=1).get_profile()
profile.iban_bban = 'FR76 1234 1234 1234 1234 1234 123'
profile.bic = 'CCBPFRABCDE'

profile.register = AUTOENTREPRENEUR_REGISTER_RSEIRL
profile.registration_city = 'Paris'
profile.save()

customer_address = self.proposal.project.customer.address
customer_address.street = u"128 boulevard des champs élysées\nEspace ZAC du champs de mars\nBP 140"
customer_address.zipcode = '75001'
customer_address.city = 'Paris CEDEX 1'
customer_address.save()

i = Invoice.objects.create(customer_id=self.proposal.project.customer_id,
invoice_id=1,
state=INVOICE_STATE_EDITED,
amount='1000',
edition_date=datetime.date(2010, 8, 31),
payment_date=datetime.date(2010, 9, 30),
paid_date=None,
payment_type=PAYMENT_TYPE_CHECK,
execution_begin_date=datetime.date(2010, 8, 1),
execution_end_date=datetime.date(2010, 8, 7),
penalty_date=datetime.date(2010, 10, 8),
penalty_rate='1.5',
discount_conditions='Nothing',
owner_id=1)

i_row = InvoiceRow.objects.create(proposal_id=self.proposal.id,
invoice_id=i.id,
label='Day of work',
category=ROW_CATEGORY_SERVICE,
quantity=10,
unit_price='100',
balance_payments=False,
owner_id=1)

response = self.client.get(reverse('invoice_download', kwargs={'id': i.id}))
self.assertEqual(response.status_code, 200)
f = open('/tmp/invoice_with_registration.pdf', 'w')
f.write(response.content)
f.close()
content = response.content.split("\n")
invariant_content = content[0:66] + content[67:110] + content[111:-1]
self.assertEquals(hashlib.md5("\n".join(invariant_content)).hexdigest(),
"e40423e4ab500b4816a5436e796d829f")

def testBug240(self):
"""
& character in proposal/invoice label crashes pdf download
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# encoding: utf-8
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models

class Migration(SchemaMigration):

def forwards(self, orm):

# Adding field 'UserProfile.register'
db.add_column('autoentrepreneur_userprofile', 'register', self.gf('django.db.models.fields.IntegerField')(null=True, blank=True), keep_default=False)

# Adding field 'UserProfile.registration_city'
db.add_column('autoentrepreneur_userprofile', 'registration_city', self.gf('django.db.models.fields.CharField')(max_length=255, null=True, blank=True), keep_default=False)


def backwards(self, orm):

# Deleting field 'UserProfile.register'
db.delete_column('autoentrepreneur_userprofile', 'register')

# Deleting field 'UserProfile.registration_city'
db.delete_column('autoentrepreneur_userprofile', 'registration_city')


models = {
'auth.group': {
'Meta': {'object_name': 'Group'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
},
'auth.permission': {
'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
},
'auth.user': {
'Meta': {'object_name': 'User'},
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
},
'autoentrepreneur.saleslimit': {
'Meta': {'object_name': 'SalesLimit'},
'activity': ('django.db.models.fields.IntegerField', [], {}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'limit': ('django.db.models.fields.IntegerField', [], {}),
'limit2': ('django.db.models.fields.IntegerField', [], {}),
'year': ('django.db.models.fields.IntegerField', [], {})
},
'autoentrepreneur.subscription': {
'Meta': {'object_name': 'Subscription', '_ormbases': ['core.OwnedObject']},
'error_message': ('django.db.models.fields.CharField', [], {'max_length': '150', 'null': 'True', 'blank': 'True'}),
'expiration_date': ('django.db.models.fields.DateField', [], {'db_index': 'True'}),
'ownedobject_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['core.OwnedObject']", 'unique': 'True', 'primary_key': 'True'}),
'state': ('django.db.models.fields.IntegerField', [], {'db_index': 'True'}),
'transaction_id': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '50'})
},
'autoentrepreneur.userprofile': {
'Meta': {'object_name': 'UserProfile'},
'activity': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
'address': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contact.Address']"}),
'bic': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '11', 'blank': 'True'}),
'company_id': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '50', 'blank': 'True'}),
'company_name': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255', 'blank': 'True'}),
'creation_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
'creation_help': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'freeing_tax_payment': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'iban_bban': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '34', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'logo_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
'payment_option': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
'phonenumber': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '20', 'blank': 'True'}),
'professional_category': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
'professional_email': ('django.db.models.fields.EmailField', [], {'default': "''", 'max_length': '75', 'blank': 'True'}),
'register': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
'registration_city': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
'unregister_datetime': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
'user': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['auth.User']", 'unique': 'True'}),
'uuid': ('django.db.models.fields.CharField', [], {'default': "''", 'unique': 'True', 'max_length': '36'}),
'vat_number': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '20', 'null': 'True', 'blank': 'True'})
},
'contact.address': {
'Meta': {'object_name': 'Address', '_ormbases': ['core.OwnedObject']},
'city': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255', 'blank': 'True'}),
'country': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contact.Country']", 'null': 'True', 'blank': 'True'}),
'ownedobject_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['core.OwnedObject']", 'unique': 'True', 'primary_key': 'True'}),
'street': ('django.db.models.fields.TextField', [], {'default': "''", 'blank': 'True'}),
'zipcode': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '10', 'blank': 'True'})
},
'contact.country': {
'Meta': {'ordering': "['country_name']", 'object_name': 'Country'},
'country_code2': ('django.db.models.fields.CharField', [], {'max_length': '2'}),
'country_code3': ('django.db.models.fields.CharField', [], {'max_length': '3'}),
'country_name': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
},
'contenttypes.contenttype': {
'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
},
'core.ownedobject': {
'Meta': {'object_name': 'OwnedObject'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'owner': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}),
'uuid': ('django.db.models.fields.CharField', [], {'default': "''", 'unique': 'True', 'max_length': '36'})
}
}

complete_apps = ['autoentrepreneur']
9 changes: 9 additions & 0 deletions autoentrepreneur/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,13 @@ def __unicode__(self):
AUTOENTREPRENEUR_PROFESSIONAL_CATEGORY_CRAFTSMAN_ALSACE: 0.17,
AUTOENTREPRENEUR_PROFESSIONAL_CATEGORY_LIBERAL: 0.2}

AUTOENTREPRENEUR_REGISTER_RM = 1
AUTOENTREPRENEUR_REGISTER_RCS = 2
AUTOENTREPRENEUR_REGISTER_RSEIRL = 3
AUTOENTREPRENEUR_REGISTER = ((AUTOENTREPRENEUR_REGISTER_RM, 'RM'),
(AUTOENTREPRENEUR_REGISTER_RCS, 'RCS'),
(AUTOENTREPRENEUR_REGISTER_RSEIRL, 'RSEIRL'))

store = FileSystemStorage(location=settings.FILE_UPLOAD_DIR)

def logo_upload_to_handler(instance, filename):
Expand All @@ -171,6 +178,8 @@ class UserProfile(models.Model):
logo_file = models.FileField(upload_to=logo_upload_to_handler, null=True, blank=True, storage=store, verbose_name=_('Custom header'), help_text=_('will appear in place of your personnal informations on proposals and invoices. Maximum width and height: 252x137'))
uuid = models.CharField(max_length=36, unique=True, default=uuid.uuid4)
vat_number = models.CharField(max_length=20, default='', null=True, blank=True, verbose_name=_('VAT number'), help_text=_('If you overrun the second sales limit, you need to declare VAT. Filling this field enables VAT management on invoices'))
register = models.IntegerField(choices=AUTOENTREPRENEUR_REGISTER, null=True, blank=True, verbose_name=_('Registration register'))
registration_city = models.CharField(max_length=255, null=True, blank=True, verbose_name=_('Registration city'))

def __unicode__(self):
return self.user.__unicode__()
Expand Down
8 changes: 8 additions & 0 deletions autoentrepreneur/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ class SubscriptionTest(TestCase):

def setUp(self):
Subscription.objects.all().delete()
today = datetime.date.today()
# generate limit for next year
sale_limits = SalesLimit.objects.filter(year=today.year)
for sl in sale_limits:
SalesLimit.objects.create(year=sl.year + 1,
activity=sl.activity,
limit=sl.limit,
limit2=sl.limit2)

def testNotAllowedIfNoSubscription(self):
user = User.objects.get(pk=1)
Expand Down
4 changes: 4 additions & 0 deletions core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,10 @@ def settings_edit(request):
if request.method == 'POST':
userform = UserForm(request.POST, prefix="user", instance=user)
profileform = UserProfileForm(request.POST, request.FILES, prefix="profile", instance=profile)
if request.POST.get('profile-register'):
profileform.fields['registration_city'].required = True
if request.POST.get('profile-registration_city'):
profileform.fields['register'].required = True
addressform = AddressForm(request.POST, prefix="address", instance=address)

if userform.is_valid() and profileform.is_valid() and addressform.is_valid():
Expand Down
Binary file modified locale/en/LC_MESSAGES/django.mo
Binary file not shown.
Loading

0 comments on commit c3e64d3

Please sign in to comment.