# Path: spacescout_web/forms/share.py
# class ShareForm(forms.Form):
#         back = forms.CharField(widget=forms.HiddenInput())
#         spot_id = forms.IntegerField(widget=forms.HiddenInput())
#         sender = forms.EmailField(
#             max_length=128,
#             label="From",
#             required=True,
#             error_messages={'required': 'Required field'})
#         recipient = EmailListField(
#             max_length=1028,
#             label="To",
#             required=True,
#             error_messages={'required': 'Required field'})
#         subject = forms.CharField(max_length=128,
#                                   label="Subject",
#                                   required=True)
#         message = forms.CharField(
#             widget=forms.Textarea(attrs={'rows': 5}),
#             label="Your Message (optional)",
#             required=False)
#         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
# def validate_back_link(back):
#     if not re.match(r'^(/|%2F)', back):
#         raise(Exception('Invalid Back Link'))


from django.shortcuts import render_to_response
from django.template import RequestContext
from django.contrib.auth.decorators import login_required
from django.http import HttpResponseRedirect, Http404
from spacescout_web.forms.share import ShareForm
from django.conf import settings
from django.utils.http import urlquote
from spacescout_web.spot import Spot, SpotException
from spacescout_web.views.contact import validate_back_link
import oauth2
import socket
import simplejson as json
import logging
                }

            resp, content = client.request(url,
                                           method='GET',
                                           headers=headers)

            sender = "%s@%s" % (
                                request.user.username,
                                getattr(settings, 'SS_MAIL_DOMAIN', 'uw.edu')
                                )
            if resp.status == 200:
                me = content = json.loads(content)
                if 'email' in me and len(me['email']):
                    sender = me['email']
        else:
            sender = ''

        form = ShareForm(initial={
                'spot_id': spot_id,
                'back': back,
                'sender': sender,
                'subject': 'Check out this space I found on SpaceScout',
            })

    try:
        spot = Spot(spot_id).get()
        share_text = [spot["name"], spot["type"]]
        if ('extended_info' in spot and
                'location_description' in spot['extended_info']):
            share_text.append(spot['extended_info']['location_description'])

# Path: spacescout_web/forms/share.py
# class ShareForm(forms.Form):
#         back = forms.CharField(widget=forms.HiddenInput())
#         spot_id = forms.IntegerField(widget=forms.HiddenInput())
#         sender = forms.EmailField(
#             max_length=128,
#             label="From",
#             required=True,
#             error_messages={'required': 'Required field'})
#         recipient = EmailListField(
#             max_length=1028,
#             label="To",
#             required=True,
#             error_messages={'required': 'Required field'})
#         subject = forms.CharField(max_length=128,
#                                   label="Subject",
#                                   required=True)
#         message = forms.CharField(
#             widget=forms.Textarea(attrs={'rows': 5}),
#             label="Your Message (optional)",
#             required=False)
#         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
# def validate_back_link(back):
#     if not re.match(r'^(/|%2F)', back):
#         raise(Exception('Invalid Back Link'))


# Path: spacescout_web/views/share.py
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.contrib.auth.decorators import login_required
from django.http import HttpResponseRedirect, Http404
from spacescout_web.forms.share import ShareForm
from django.conf import settings
from django.utils.http import urlquote
from spacescout_web.spot import Spot, SpotException
from spacescout_web.views.contact import validate_back_link
import oauth2
import socket
import simplejson as json
import logging

                }

            resp, content = client.request(url,
                                           method='GET',
                                           headers=headers)

            sender = "%s@%s" % (
                                request.user.username,
                                getattr(settings, 'SS_MAIL_DOMAIN', 'uw.edu')
                                )
            if resp.status == 200:
                me = content = json.loads(content)
                if 'email' in me and len(me['email']):
                    sender = me['email']
        else:
            sender = ''

        form = ShareForm(initial={
                'spot_id': spot_id,
                'back': back,
                'sender': sender,
                'subject': 'Check out this space I found on SpaceScout',
            })

    try:
        spot = Spot(spot_id).get()
        share_text = [spot["name"], spot["type"]]
        if ('extended_info' in spot and
                'location_description' in spot['extended_info']):
            share_text.append(spot['extended_info']['location_description'])

    except SpotException as e: