<commit_before># -*- coding: utf-8 -*-
from __future__ import unicode_literals

from allink_core.allink_base.views import AllinkBasePluginLoadMoreView, AllinkBaseDetailView, AllinkBaseCreateView
from allink_core.allink_mandrill.config import MandrillConfig
from allink_core.allink_terms.models import AllinkTerms

from allink_apps.blog.models import Blog, BlogAppContentPlugin, EventsRegistration, Events
from allink_apps.blog.forms import EventsRegistrationForm
from allink_apps.blog.email import send_registration_confirmation_email, send_registration_email

config = MandrillConfig()


class BlogPluginLoadMore(AllinkBasePluginLoadMoreView):
    model = Blog
    plugin_model = BlogAppContentPlugin


class BlogDetail(AllinkBaseDetailView):
    model = Blog

    def get_template_names(self):
        names = []
        if hasattr(self.object, 'events'):
            name = self.object.events._meta.model_name
        elif hasattr(self.object, 'news'):
            name = self.object.news._meta.model_name
        else:
            name = self.object._meta.model_name

        names.append("%s/%s%s.html" % (name, name, self.template_name_suffix))
        return names


class EventsRegistrationView(AllinkBaseCreateView):
    model = EventsRegistration
    form_class = EventsRegistrationForm
    template_name = 'events/forms/registration.html'

    def get_context_data(self, **kwargs):
        context = super(AllinkBaseCreateView, self).get_context_data(**kwargs)
        context.update({
            'slug': self.kwargs.get('slug', None)<commit_msg>fixes news detail<commit_after># -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.core.exceptions import ObjectDoesNotExist
from allink_core.allink_base.views import AllinkBasePluginLoadMoreView, AllinkBaseDetailView, AllinkBaseCreateView
from allink_core.allink_mandrill.config import MandrillConfig
from allink_core.allink_terms.models import AllinkTerms

from allink_apps.blog.models import Blog, BlogAppContentPlugin, EventsRegistration, Events
from allink_apps.blog.forms import EventsRegistrationForm
from allink_apps.blog.email import send_registration_confirmation_email, send_registration_email

config = MandrillConfig()


class BlogPluginLoadMore(AllinkBasePluginLoadMoreView):
    model = Blog
    plugin_model = BlogAppContentPlugin


class BlogDetail(AllinkBaseDetailView):
    model = Blog

    def get_template_names(self):
        names = []
        try:
            name = self.object.events._meta.model_name
        except ObjectDoesNotExist:
            pass

        try:
            name = self.object.events._meta.model_name
        except ObjectDoesNotExist:
            name = self.object._meta.model_name

        names.append("%s/%s%s.html" % (name, name, self.template_name_suffix))
        return names


class EventsRegistrationView(AllinkBaseCreateView):
    model = EventsRegistration
    form_class = EventsRegistrationForm
    template_name = 'events/forms/registration.html'

    def get_context_data(self, **kwargs):
        context = super(AllinkBaseCreateView, self).get_context_data(**kwargs)
        context.update({
            'slug': self.kwargs.get('slug', None)
{'fraction_non_alphanumeric': 0.07993730407523511, 'fraction_numerical': 0.0006269592476489029, 'mean_word_length': 4.065079365079365, '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': '4459568', 'n_tokens_mistral': 920, 'n_tokens_neox': 889, 'n_words': 183}