Revision 698016f7 snf-astakos-app/astakos/oa2/models.py

b/snf-astakos-app/astakos/oa2/models.py
32 32
# or implied, of GRNET S.A.
33 33

  
34 34
import datetime
35
import urlparse
36 35

  
37 36
from django.db import models
38 37
from django.utils.translation import ugettext_lazy as _
......
87 86
        return self.redirecturl_set.get().url
88 87

  
89 88
    def redirect_uri_is_valid(self, uri):
90
        # ignore user specific uri part
91
        parts = list(urlparse.urlsplit(uri))
92
        path = parts[2]
93
        pieces = path.rsplit('/', 3)
94
        parts[2] = '/'.join(pieces[:-3]) if len(pieces) > 3 else path
95
        uri = urlparse.urlunsplit(parts)
96

  
97
        # TODO: handle trailing slashes
98
        return self.redirecturl_set.filter(url=uri).count() > 0
89
        for redirect_uri in self.redirecturl_set.values_list('url', flat=True):
90
            if uri == redirect_uri:
91
                return True
92
            elif uri.startswith(redirect_uri.rstrip('/') + '/'):
93
                return True
94
        return False
99 95

  
100 96
    def get_id(self):
101 97
        return self.identifier

Also available in: Unified diff