コード例 #1
0
ファイル: admin.py プロジェクト: amagidow/dialects
 def get_queryset(self, request): #tutorials say to use function 'queryset' but that's not true, get_queryset seems to be the on that actually works
     qs = super(LanguageDatumAdmin, self).get_queryset(request)
     if request.user.is_superuser:
         return qs #super user can see everyone's to allow for removal of bad data
     else:
         #Note that this does NOT inherit the queryset from super. Bad programming, but doesn't seem to matter right now
         qs= permissionwrapper(request.user) #normal users can only see their own contributions
         return qs
コード例 #2
0
ファイル: paradigms.py プロジェクト: amagidow/dialects
 def getDatumsFromTags(self, dialect, tags, user=None):  # utilty function for in templates
     # print("DialectCode is: {}".format(dialect))
     dialect = dialect.strip()  # clear whitespace
     # Add User argument with default "none", hit the permission function first, filter on that
     myQuery = utilityfuncs.permissionwrapper(user)
     myQuery = myQuery.filter(dialect__dialectCode=dialect)  # Need to have some user filtering here
     # print("Base languageDatum: {}".format(str(myQuery).encode('ascii', errors='backslashreplace')))
     tags = set(tags)
     tags = filter(None, tags)  # remove blanks
     # print("Tags to Retrieve are: {}".format(tags))
     # print("getDatumFromTags:{}".format(tags))
     for tag in tags:
         tag = tag.strip()
         myQuery = myQuery.filter(entryTags__tagText=tag)
         # print("QueryReturned: {}".format(str(myQuery).encode('ascii', errors='backslashreplace')))
     return myQuery