Skip to content

Commit

Permalink
Fix using the correct Site object for the response URL
Browse files Browse the repository at this point in the history
  • Loading branch information
eht16 committed May 14, 2013
1 parent ae6b364 commit 56a91ea
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions pastebin/views.py
Expand Up @@ -3,12 +3,12 @@
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

Expand Down Expand Up @@ -233,6 +233,14 @@ def guess_lexer(request):
return HttpResponse(response)


#----------------------------------------------------------------------
def _get_site(request):
if hasattr(request, 'site'):
return request.site
else:
return Site.objects.get_current()


#----------------------------------------------------------------------
@require_POST
@csrf_exempt
Expand All @@ -246,7 +254,7 @@ def api_create(request):
except SnippetValidationError, e:
return HttpResponseBadRequest(unicode(e), content_type=u'text/plain')

site = Site.objects.get_current()
site = _get_site(request)
absolute_url = snippet.get_absolute_url()
result = u'http://%s%s' % (site.domain, absolute_url)
result = u'http://%s%s/' % (site.domain, absolute_url)
return HttpResponse(result, content_type=u'text/plain')

0 comments on commit 56a91ea

Please sign in to comment.