# Path: rtei/data.py
# def get_json_file(path, ordered_dict=True):
# def get_file_path(file_name, year=''):
# def get_indicators(year):
# def get_themes(year):
# def get_countries():
# def get_scores_per_country(year):
# def get_c3_scores_per_country(year):
# def get_indicators_for_country(country_code, year):
# def get_countries_with_data():
# def get_country_name(country_code):
# 
# Path: rtei/forms.py
# class ContactForm(forms.Form):
#     contact_name = forms.CharField(
#         label=_('Name'), max_length=100,
#         widget=forms.TextInput(attrs={'class': "short"}))
#     contact_email = forms.EmailField(
#         label=_('Email'), widget=forms.TextInput(attrs={'class': "short"}))
#     contact_affiliation = forms.CharField(
#         label=_('Affiliation'), max_length=256,
#         widget=forms.TextInput(attrs={'class': "short"}))
# 
#     def save(self):
#         message = '''A user has submitted the contact form with the following details:
# 
# Name: {0}
# Email: {1}
# Affiliation: {2}'''.format(self.cleaned_data['contact_name'],
#                            self.cleaned_data['contact_email'],
#                            self.cleaned_data['contact_affiliation'])
# 
#         send_mail('[RTEI] New Contact', message, 'no-reply@results.org',
#                   [settings.RTEI_CONTACT_FORM_EMAIL], fail_silently=False)


import sys
import json
import logging
from collections import OrderedDict
from smtplib import SMTPException
from django.db import models
from django.http import Http404
from django.utils.translation import ugettext as _
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.core.validators import RegexValidator, URLValidator
from django.shortcuts import redirect
from django.contrib import messages
from django.conf import settings
from wagtail.core.models import Page, get_root_collection_id
from wagtail.core.fields import RichTextField
from wagtail.admin.edit_handlers import FieldPanel
from wagtail.documents.models import AbstractDocument
from wagtail.images.edit_handlers import ImageChooserPanel
from wagtail.search import index
from modelcluster.fields import ParentalKey
from modelcluster.tags import ClusterTaggableManager
from taggit.models import TaggedItemBase
from rtei import data
from rtei.forms import ContactForm
                               self.slug.replace('-', '_'))


class RTEIAncillaryPage(Page):
    '''About page and other static content pages.'''

    body = RichTextField(blank=True)

    content_panels = Page.content_panels + [
        FieldPanel('body', classname="full")
    ]

    search_fields = Page.search_fields + [
        index.SearchField('body'),
    ]

    def get_context(self, request):
        context = super(RTEIAncillaryPage, self).get_context(request)
        if self.slug == 'contact-us':
            if request.method == 'POST':
                contact_form = ContactForm(request.POST)
            else:
                contact_form = ContactForm()
            context['contact_form'] = contact_form
        elif self.slug in ['supporters', 'civil-society-partners']:
            context['listing'] = True
        return context

    def serve(self, request):
        if self.slug == 'contact-us' and request.method == 'POST':

# Path: rtei/data.py
# def get_json_file(path, ordered_dict=True):
# def get_file_path(file_name, year=''):
# def get_indicators(year):
# def get_themes(year):
# def get_countries():
# def get_scores_per_country(year):
# def get_c3_scores_per_country(year):
# def get_indicators_for_country(country_code, year):
# def get_countries_with_data():
# def get_country_name(country_code):
# 
# Path: rtei/forms.py
# class ContactForm(forms.Form):
#     contact_name = forms.CharField(
#         label=_('Name'), max_length=100,
#         widget=forms.TextInput(attrs={'class': "short"}))
#     contact_email = forms.EmailField(
#         label=_('Email'), widget=forms.TextInput(attrs={'class': "short"}))
#     contact_affiliation = forms.CharField(
#         label=_('Affiliation'), max_length=256,
#         widget=forms.TextInput(attrs={'class': "short"}))
# 
#     def save(self):
#         message = '''A user has submitted the contact form with the following details:
# 
# Name: {0}
# Email: {1}
# Affiliation: {2}'''.format(self.cleaned_data['contact_name'],
#                            self.cleaned_data['contact_email'],
#                            self.cleaned_data['contact_affiliation'])
# 
#         send_mail('[RTEI] New Contact', message, 'no-reply@results.org',
#                   [settings.RTEI_CONTACT_FORM_EMAIL], fail_silently=False)


# Path: rtei/models.py
import sys
import json
import logging
from collections import OrderedDict
from smtplib import SMTPException
from django.db import models
from django.http import Http404
from django.utils.translation import ugettext as _
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.core.validators import RegexValidator, URLValidator
from django.shortcuts import redirect
from django.contrib import messages
from django.conf import settings
from wagtail.core.models import Page, get_root_collection_id
from wagtail.core.fields import RichTextField
from wagtail.admin.edit_handlers import FieldPanel
from wagtail.documents.models import AbstractDocument
from wagtail.images.edit_handlers import ImageChooserPanel
from wagtail.search import index
from modelcluster.fields import ParentalKey
from modelcluster.tags import ClusterTaggableManager
from taggit.models import TaggedItemBase
from rtei import data
from rtei.forms import ContactForm

                               self.slug.replace('-', '_'))


class RTEIAncillaryPage(Page):
    '''About page and other static content pages.'''

    body = RichTextField(blank=True)

    content_panels = Page.content_panels + [
        FieldPanel('body', classname="full")
    ]

    search_fields = Page.search_fields + [
        index.SearchField('body'),
    ]

    def get_context(self, request):
        context = super(RTEIAncillaryPage, self).get_context(request)
        if self.slug == 'contact-us':
            if request.method == 'POST':
                contact_form = ContactForm(request.POST)
            else:
                contact_form = ContactForm()
            context['contact_form'] = contact_form
        elif self.slug in ['supporters', 'civil-society-partners']:
            context['listing'] = True
        return context

    def serve(self, request):
        if self.slug == 'contact-us' and request.method == 'POST':

            contact_form = ContactForm(request.POST)