<commit_before># -*- coding: utf-8 -*-
# Copyright 2013 UNED
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from django.contrib.auth.models import User
from django.db import connection, models
from django.db.models import signals
from django.dispatch import receiver
from django.utils.translation import ugettext_lazy as _
from django.core.urlresolvers import reverse

from moocng.courses.models import Announcement

from moocng.mongodb import get_micro_blog_db
import pymongo
from dateutil import tz
from datetime import date, datetime
from bson.objectid import ObjectId
import re

class Organization(models.Model):
    name = models.CharField(verbose_name=_(u"Organization name"),
                                    max_length=256)
    logo = models.ImageField(upload_to="organizations",
                            # height_field=256,
                            # width_field=256,
                            verbose_name=_(u"Organization logo"),
                            max_length=256)

    def __unicode__(self):
        return unicode(self.name)


class UserProfile(models.Model):
    user = models.ForeignKey(User, verbose_name=_('User'))
    last_announcement = models.ForeignKey(Announcement,
                                          verbose_name=_('Last announcement viewed'),
                                          null=True,
                                          blank=True)

    organization = models.ManyToManyField(Organization, verbose_name=_(u'Organization'),
                                                        null=True,
                                                        blank=True)
    GENDER_CHOICES = (
        ('male', _(u'Male')),
        ('female', _(u'Female'))
    )
    gender = models.CharField(verbose_name=_(u"Gender"),
                                    max_length=6,
                                    choices=GENDER_CHOICES,
                                    null=True,
                                    blank=True)
    personalweb = models.CharField(verbose_name=_(u"Personal website"),
                                    max_length=256,
                                    null=True,
                                    blank=True)
    birthdate = models.DateField(verbose_name=_(u"Birthdate"),
                                    null=True,
                                    blank=True)
    bio = models.TextField(verbose_name=_(u"Biography"),
                                    null=True,
                                    blank=True)
    karma = models.IntegerField(verbose_name=_(u"Karma"),
                                    default=0)
    postal_code = models.CharField(verbose_name=_(u"Postal code"),
                                    max_length=10,
                                    null=True,
                                    blank=True)
    city = models.CharField(verbose_name=_(u"City"),
                            max_length=100,
                            null=True,
                            blank=True)
    country = models.CharField(verbose_name=_(u"Country"),
                            max_length=100,
                            null=True,
                            blank=True)
    language = models.CharField(verbose_name=_(u"Language"),
                            max_length=2,
                            null=True,
                            blank=True)
    middle_name = models.CharField(verbose_name=_(u"Middle name"),
                            max_length=100,
                            null=True,
                            blank=True)
    interests = models.CharField(verbose_name=_(u"Interests"),
                            max_length=30,
                            null=True,
                            blank=True)
    sub = models.CharField(verbose_name=_(u"Global ID"),
                            max_length=24,
                            null=True,
                            blank=True)
    

    class Meta:
        verbose_name = _('User profile')
        verbose_name_plural = _('User profiles')

    def __unicode__(self):
        return unicode(self.user)

    def interests_as_list(self):
        return self.interests.split(',')

    def interests_name_as_list(self):
        interests_name = {
            'ES': 'Educational Sciences',
            'SS': 'Social Sciences',
            'H': 'Humanities',
            'NSM': 'Natural Sciences and Mathematics',
            'BS': 'Biomedical Sciences',
            'TS': 'Technological Sciences'
        }
        interests_list = []
	if self.interests is not None:
	        for interest in self.interests.split(','):
        	    interests_list.append(interests_name[interest])
        
        return interests_list
<commit_msg>Fix profile interests<commit_after># -*- coding: utf-8 -*-
# Copyright 2013 UNED
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from django.contrib.auth.models import User
from django.db import connection, models
from django.db.models import signals
from django.dispatch import receiver
from django.utils.translation import ugettext_lazy as _
from django.core.urlresolvers import reverse

from moocng.courses.models import Announcement

from moocng.mongodb import get_micro_blog_db
import pymongo
from dateutil import tz
from datetime import date, datetime
from bson.objectid import ObjectId
import re

class Organization(models.Model):
    name = models.CharField(verbose_name=_(u"Organization name"),
                                    max_length=256)
    logo = models.ImageField(upload_to="organizations",
                            # height_field=256,
                            # width_field=256,
                            verbose_name=_(u"Organization logo"),
                            max_length=256)

    def __unicode__(self):
        return unicode(self.name)


class UserProfile(models.Model):
    user = models.ForeignKey(User, verbose_name=_('User'))
    last_announcement = models.ForeignKey(Announcement,
                                          verbose_name=_('Last announcement viewed'),
                                          null=True,
                                          blank=True)

    organization = models.ManyToManyField(Organization, verbose_name=_(u'Organization'),
                                                        null=True,
                                                        blank=True)
    GENDER_CHOICES = (
        ('male', _(u'Male')),
        ('female', _(u'Female'))
    )
    gender = models.CharField(verbose_name=_(u"Gender"),
                                    max_length=6,
                                    choices=GENDER_CHOICES,
                                    null=True,
                                    blank=True)
    personalweb = models.CharField(verbose_name=_(u"Personal website"),
                                    max_length=256,
                                    null=True,
                                    blank=True)
    birthdate = models.DateField(verbose_name=_(u"Birthdate"),
                                    null=True,
                                    blank=True)
    bio = models.TextField(verbose_name=_(u"Biography"),
                                    null=True,
                                    blank=True)
    karma = models.IntegerField(verbose_name=_(u"Karma"),
                                    default=0)
    postal_code = models.CharField(verbose_name=_(u"Postal code"),
                                    max_length=10,
                                    null=True,
                                    blank=True)
    city = models.CharField(verbose_name=_(u"City"),
                            max_length=100,
                            null=True,
                            blank=True)
    country = models.CharField(verbose_name=_(u"Country"),
                            max_length=100,
                            null=True,
                            blank=True)
    language = models.CharField(verbose_name=_(u"Language"),
                            max_length=2,
                            null=True,
                            blank=True)
    middle_name = models.CharField(verbose_name=_(u"Middle name"),
                            max_length=100,
                            null=True,
                            blank=True)
    interests = models.CharField(verbose_name=_(u"Interests"),
                            max_length=30,
                            null=True,
                            blank=True)
    sub = models.CharField(verbose_name=_(u"Global ID"),
                            max_length=24,
                            null=True,
                            blank=True)
    

    class Meta:
        verbose_name = _('User profile')
        verbose_name_plural = _('User profiles')

    def __unicode__(self):
        return unicode(self.user)

    def interests_as_list(self):
        return self.interests.split(',')

    def interests_name_as_list(self):
        interests_name = {
            'ES': 'Educational Sciences',
            'SS': 'Social Sciences',
            'HUM': 'Humanities',
            'NSM': 'Natural Sciences and Mathematics',
            'BS': 'Biomedical Sciences',
            'TS': 'Technological Sciences'
        }
        interests_list = []
        if self.interests is not None:
            for interest in self.interests.split(','):
                try:
                   interests_list.append(interests_name[interest])
                except:
                    pass
        return interests_list

{'fraction_non_alphanumeric': 0.08229592321581299, 'fraction_numerical': 0.007982514492065001, 'mean_word_length': 1.435547327007637, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 52, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1746418', 'n_tokens_mistral': 2630, 'n_tokens_neox': 2480, 'n_words': 577}