Commit 456d0aa7 authored by Jean Michel Rouly's avatar Jean Michel Rouly
Browse files

Don't depend on the sites framework to identify app domain.

parent 53ace96d
......@@ -26,12 +26,6 @@ class URL( models.Model ):
class Meta:
ordering = ['short']
def get_absolute_url(self):
from django.contrib.sites.models import Site
current_site = Site.objects.get_current()
site_url = current_site.domain
return "%s/%s" % (site_url, self.short)
@staticmethod
def generate_valid_short():
selection = string.ascii_lowercase + string.digits
......
......@@ -32,21 +32,22 @@
</div>
<div class="col-md-4">
{% qr_from_text url.get_absolute_url 's' %}
<a class="share" href="http://twitter.com/share?url={{ url.get_absolute_url }}" target="_blank" title="Share via Twitter">
{% with domain|add:url.short as the_url %}
{% qr_from_text the_url 's' %}
<a class="share" href="http://twitter.com/share?url={{ the_url }}" target="_blank" title="Share via Twitter">
<i class="fa fa-twitter-square fa-3x"></i>
</a>
<a class="share" href="http://www.facebook.com/share.php?u={{ url.get_absolute_url }}" target="_blank" title="Share via Facebook">
<a class="share" href="http://www.facebook.com/share.php?u={{ the_url }}" target="_blank" title="Share via Facebook">
<i class="fa fa-facebook-square fa-3x"></i>
</a>
<a class="share" href="https://plus.google.com/share?url={{ url.get_absolute_url }}" target="_blank" title="Share via Google+">
<a class="share" href="https://plus.google.com/share?url={{ the_url }}" target="_blank" title="Share via Google+">
<i class="fa fa-google-plus-square fa-3x"></i>
</a>
<a class="share" href="http://www.linkedin.com/shareArticle?mini=true&amp;url={{ url.get_absolute_url }}&amp;ro=false&amp;summary=&amp;source=" target="_blank" title="Share via LinkedIn">
<a class="share" href="http://www.linkedin.com/shareArticle?mini=true&amp;url={{ the_url }}&amp;ro=false&amp;summary=&amp;source=" target="_blank" title="Share via LinkedIn">
<i class="fa fa-linkedin-square fa-3x"></i>
</a>
</p>
{% endwith %}
</div>
......@@ -169,8 +169,12 @@ def my_links(request):
return render(request, 'not_registered.html')
urls = URL.objects.filter( owner = request.user )
domain = request.META.get('HTTP_HOST') + "/"
return render(request, 'my_links.html', {
'urls' : urls,
'domain' : domain,
},
)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment