X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/8f392c8987476f29a38fa33ab06c36471ff2cb98..b477b3cfa2ce28678eb6c861b286e86ed77046ee:/apps/organizations/models.py diff --git a/apps/organizations/models.py b/apps/organizations/models.py index 9d3300a2..8e04ddb7 100644 --- a/apps/organizations/models.py +++ b/apps/organizations/models.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.core.urlresolvers import reverse @@ -5,8 +6,7 @@ from django.contrib.auth.models import User from django.db import models from django.utils.encoding import python_2_unicode_compatible from django.template.loader import render_to_string -from django.utils import translation -#from jsonfield import JSONField +from django.utils import translation countries = [ @@ -71,7 +71,7 @@ class Card(models.Model): def get_projects(self): for project_line in self.projects.strip().split('\n'): - parts = project_line.strip().split(' ', 2) + parts = project_line.strip().split(None, 2) if not parts or not parts[0]: continue url, lang, desc = (parts + [''] * 2)[:3] @@ -83,13 +83,14 @@ class Card(models.Model): p = getattr(self, "preview_html_%s" % lang) assert p return p - except: + except (AssertionError, AttributeError): return self.preview_html + @python_2_unicode_compatible class UserCard(Card): preview_html_template = 'organizations/snippets/user.html' - user = models.ForeignKey(User, unique=True, primary_key=True) + user = models.OneToOneField(User, primary_key=True) def __str__(self): return str(self.user) @@ -103,7 +104,7 @@ class Organization(Card): preview_html_template = 'organizations/snippets/organization.html' name = models.CharField(max_length=1024) - tags = models.ManyToManyField('catalogue.Tag') + tags = models.ManyToManyField('catalogue.Tag', blank=True) # logo = models.ImageField(upload_to='people/logo', blank=True) # country = models.CharField(max_length=64, blank=True, choices=countries) # www = models.URLField(blank=True)