<commit_before># encoding: utf-8

"""Event model."""

import mongoengine as db

from web.extras.contentment.components.page.model import Page
from widgets import fields


log = __import__('logging').getLogger(__name__)
__all__ = ['EventContact', 'Event']



class EventContact(db.EmbeddedDocument):
    name = db.StringField(max_length=250)
    email = db.StringField(max_length=250)
    phone = db.StringField(max_length=64)


class Event(Page):
    _widgets = fields
    
    default = db.StringField(default="view:event", max_length=128)
    
    organizer = db.StringField(max_length=250)
    location = db.StringField(max_length=250)
    starts = db.DateTimeField()
    stops = db.DateTimeField()
    allday = db.BooleanField(default=False)
    contact = db.EmbeddedDocumentField(EventContact)<commit_msg>Fix for inability to define contact information.<commit_after># encoding: utf-8

"""Event model."""

import mongoengine as db

from web.extras.contentment.components.page.model import Page
from widgets import fields


log = __import__('logging').getLogger(__name__)
__all__ = ['EventContact', 'Event']



class EventContact(db.EmbeddedDocument):
    name = db.StringField(max_length=250)
    email = db.StringField(max_length=250)
    phone = db.StringField(max_length=64)


class Event(Page):
    _widgets = fields
    
    default = db.StringField(default="view:event", max_length=128)
    
    organizer = db.StringField(max_length=250)
    location = db.StringField(max_length=250)
    starts = db.DateTimeField()
    stops = db.DateTimeField()
    allday = db.BooleanField(default=False)
    contact = db.EmbeddedDocumentField(EventContact)
    
    def process(self, formdata):
        formdata = super(Event, self).process(formdata)
        
        contact = EventContact()
        
        for field in 'name', 'email', 'phone':
            combined = 'contact.' + field
            if combined in formdata:
                setattr(contact, field, formdata[combined])
                del formdata[combined]
        
        formdata['contact'] = contact
        
        return formdata
    
{'fraction_non_alphanumeric': 0.109478672985782, 'fraction_numerical': 0.017061611374407582, 'mean_word_length': 3.407098121085595, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3864003', 'n_tokens_mistral': 664, 'n_tokens_neox': 628, 'n_words': 133}