def get_authorlist(self): """ return [ x for x in self.authorlist.all() ] but in the order of the text entry """ text_list = parsewords(self, fieldname='authors', is_sorted=False) all_authors = [] for author in text_list: all_authors.append(Author.objects.get(name=author)) return all_authors
def clean_list(objname, fieldname): curlist = [] allsoft = Revision.objects.all() for cursoft in allsoft: tlist = parsewords(cursoft, fieldname) for item in tlist: curlist.append(item) oldlist = eval(objname + '.objects.all()') for item in oldlist: if item.name not in curlist: item.delete()
def clean_list(objname,fieldname): curlist = [] allsoft = Revision.objects.all() for cursoft in allsoft: tlist = parsewords(cursoft,fieldname) for item in tlist: curlist.append(item) oldlist = eval(objname+'.objects.all()') for item in oldlist: if item.name not in curlist: item.delete()
def update_list(self,listname,objname,fieldname): current = eval('self.'+listname+'.all()') newlist = parsewords(self,fieldname=fieldname) # clear out old items for item in current: if item.name not in newlist: eval('self.'+listname+'.remove(item)') # add new items for item_name in newlist: if item_name not in [item.name for item in current]: try: item = eval(objname+'.objects.get(name=\''+item_name+'\')') except eval(objname+'.DoesNotExist'): item = eval(objname+'(name=\''+item_name+'\')') item.save() eval('self.'+listname+'.add(item)')
def update_list(self, listname, objname, fieldname): current = eval('self.' + listname + '.all()') newlist = parsewords(self, fieldname=fieldname) # clear out old items for item in current: if item.name not in newlist: eval('self.' + listname + '.remove(item)') # add new items for item_name in newlist: if item_name not in [item.name for item in current]: try: item = eval(objname + '.objects.get(name=\'' + item_name + '\')') except eval(objname + '.DoesNotExist'): item = eval(objname + '(name=\'' + item_name + '\')') item.save() eval('self.' + listname + '.add(item)')