Skip to content

Misc. Django scripts

Dolsy Smith edited this page May 14, 2023 · 2 revisions

To retrieve information about collections with a harvest within the past year

data_to_export = []
for c in collections_harvests_past_year:
	user = c.credential.user
	last_harvest = c.last_harvest()
	coll_dict = {'name': c.name,
                'description': c.description,
                 'is_on': c.is_on,
                 'username': user.username,
                'email': user.email,
                'type': c.harvest_type,
                'id': c.id,
                'collection_id': c.collection_id}
	coll_dict.update(c.stats())
	if last_harvest:
		coll_dict['last_harvest_requested'] = last_harvest.date_requested.isoformat()
		if last_harvest.date_ended:
			coll_dict['last_harvest_concluded'] = last_harvest.date_ended.isoformat()
	data_to_export.append(coll_dict)

Clone this wiki locally