# Path: spacescout_web/forms/contact.py
# class ContactForm(BaseForm):
#         name = forms.CharField(max_length=25,
#                                label="Your Name",
#                                error_messages={'required':
#                                                'Required field'})
#         sender = forms.EmailField(max_length=40,
#                                   label="Your Email (Optional)",
#                                   required=False)
#         # feedback_choice = forms.ChoiceField((
#         #    ('', 'Please Select One'),
#         #    ('feedback', 'Leave Feedback'),
#         #    ('problem', 'Report a Problem'),
#         #    ('feature request', 'Request a Feature')),
#         #    label="Feedback Choice")
#         message = forms.CharField(widget=forms.Textarea(attrs={'rows': 5}),
#                                   label="Your Message",
#                                   error_messages={'required':
#                                                   'Required field'})
#         email_confirmation = forms.CharField(required=False)
# 
# Path: spacescout_web/spot.py
# class Spot(object):
#     def __init__(self, spot_id):
#         self.spot_id = spot_id
# 
#     def get(self):
#         # Required settings for the client
#         if not hasattr(settings, 'SS_WEB_SERVER_HOST'):
#             raise(Exception("Required setting missing: SS_WEB_SERVER_HOST"))
#         if not hasattr(settings, 'SS_WEB_OAUTH_KEY'):
#             raise(Exception("Required setting missing: SS_WEB_OAUTH_KEY"))
#         if not hasattr(settings, 'SS_WEB_OAUTH_SECRET'):
#             raise(Exception("Required setting missing: SS_WEB_OAUTH_SECRET"))
# 
#         consumer = oauth2.Consumer(
#                                 key=settings.SS_WEB_OAUTH_KEY,
#                                 secret=settings.SS_WEB_OAUTH_SECRET
#                                 )
#         client = oauth2.Client(consumer)
# 
#         url = "{0}/api/v1/spot/{1}".format(
#                                     settings.SS_WEB_SERVER_HOST,
#                                     self.spot_id
#                                     )
# 
#         resp, content = client.request(url, 'GET')
# 
#         if resp.status != 200:
#             raise SpotException(resp.status, self.spot_id)
# 
#         spot = json.loads(content)
# 
#         types = []
#         for t in spot["type"]:
#             types.append(_(t))
# 
#         spot["type"] = ','.join(types)
#         modified_date = (
#                         spot["last_modified"][5:10] +
#                         '-' +
#                         spot["last_modified"][:4]
#                         )
#         spot["last_modified"] = re.sub('-', '/', modified_date)
# 
#         return spot
# 
# class SpotException(Exception):
#     """ Exception for invalid Spot.
#     """
#     def __init__(self, resp_status, spot_id):
#         self.resp_status = resp_status
#         self.spot_id = spot_id


from django.shortcuts import render_to_response, render
from django.template import RequestContext
from django.http import HttpResponseRedirect, Http404
from spacescout_web.forms.contact import ContactForm
from spacescout_web.spot import Spot, SpotException
from django.core.mail import send_mail
from django.conf import settings
import logging
import re
    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.
"""


logger = logging.getLogger(__name__)


def contact(request, spot_id=None):
    contact_variables = _contact_variables(request, spot_id)
    if spot_id is None:
        spot_id = ''
        displayed_spot_id = 'Unknown'
    else:
        displayed_spot_id = spot_id

    back = contact_variables['back']
    spot_name = contact_variables['spot_name']
    spot_description = contact_variables['spot_description']

    if request.method == 'POST':

# Path: spacescout_web/forms/contact.py
# class ContactForm(BaseForm):
#         name = forms.CharField(max_length=25,
#                                label="Your Name",
#                                error_messages={'required':
#                                                'Required field'})
#         sender = forms.EmailField(max_length=40,
#                                   label="Your Email (Optional)",
#                                   required=False)
#         # feedback_choice = forms.ChoiceField((
#         #    ('', 'Please Select One'),
#         #    ('feedback', 'Leave Feedback'),
#         #    ('problem', 'Report a Problem'),
#         #    ('feature request', 'Request a Feature')),
#         #    label="Feedback Choice")
#         message = forms.CharField(widget=forms.Textarea(attrs={'rows': 5}),
#                                   label="Your Message",
#                                   error_messages={'required':
#                                                   'Required field'})
#         email_confirmation = forms.CharField(required=False)
# 
# Path: spacescout_web/spot.py
# class Spot(object):
#     def __init__(self, spot_id):
#         self.spot_id = spot_id
# 
#     def get(self):
#         # Required settings for the client
#         if not hasattr(settings, 'SS_WEB_SERVER_HOST'):
#             raise(Exception("Required setting missing: SS_WEB_SERVER_HOST"))
#         if not hasattr(settings, 'SS_WEB_OAUTH_KEY'):
#             raise(Exception("Required setting missing: SS_WEB_OAUTH_KEY"))
#         if not hasattr(settings, 'SS_WEB_OAUTH_SECRET'):
#             raise(Exception("Required setting missing: SS_WEB_OAUTH_SECRET"))
# 
#         consumer = oauth2.Consumer(
#                                 key=settings.SS_WEB_OAUTH_KEY,
#                                 secret=settings.SS_WEB_OAUTH_SECRET
#                                 )
#         client = oauth2.Client(consumer)
# 
#         url = "{0}/api/v1/spot/{1}".format(
#                                     settings.SS_WEB_SERVER_HOST,
#                                     self.spot_id
#                                     )
# 
#         resp, content = client.request(url, 'GET')
# 
#         if resp.status != 200:
#             raise SpotException(resp.status, self.spot_id)
# 
#         spot = json.loads(content)
# 
#         types = []
#         for t in spot["type"]:
#             types.append(_(t))
# 
#         spot["type"] = ','.join(types)
#         modified_date = (
#                         spot["last_modified"][5:10] +
#                         '-' +
#                         spot["last_modified"][:4]
#                         )
#         spot["last_modified"] = re.sub('-', '/', modified_date)
# 
#         return spot
# 
# class SpotException(Exception):
#     """ Exception for invalid Spot.
#     """
#     def __init__(self, resp_status, spot_id):
#         self.resp_status = resp_status
#         self.spot_id = spot_id


# Path: spacescout_web/views/contact.py
from django.shortcuts import render_to_response, render
from django.template import RequestContext
from django.http import HttpResponseRedirect, Http404
from spacescout_web.forms.contact import ContactForm
from spacescout_web.spot import Spot, SpotException
from django.core.mail import send_mail
from django.conf import settings
import logging
import re

    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.
"""


logger = logging.getLogger(__name__)


def contact(request, spot_id=None):
    contact_variables = _contact_variables(request, spot_id)
    if spot_id is None:
        spot_id = ''
        displayed_spot_id = 'Unknown'
    else:
        displayed_spot_id = spot_id

    back = contact_variables['back']
    spot_name = contact_variables['spot_name']
    spot_description = contact_variables['spot_description']

    if request.method == 'POST':

        form = ContactForm(request.POST)