def csv(request, format='csv'): if request.user.has_perm('contacts.can_view'): return export(Contact.objects.all(), \ ['id','node_ptr','first_seen','reporter.first_name','reporter.last_name',\ 'common_name','reporter.alias','location','gender','age_months','_locale']) return export(Contact.objects.all(), \ ['id','node_ptr','first_seen','location','gender','age_months','_locale'])
def csv(request, format='csv'): if request.user.has_perm('contacts.can_view'): return export(Contact.objects.all().order_by('node_pr'), ['node_ptr','reporter.connection.identity', 'common_name', 'messages.sent', 'messages.received', 'first_seen', '_locale']) return export(Contact.objects.all().order_by('node_pr'), ['node_ptr', 'messages.sent', 'messages.received', 'first_seen', '_locale'])
def csv(request, format='csv'): if request.user.is_authenticated(): return export(Contact.objects.all(), \ ['id','node_ptr','first_seen','given_name','family_name',\ 'common_name','unique_id','location','gender','age_months','_locale']) return export(Contact.objects.all(), \ ['id','node_ptr','first_seen','location','gender','age_months','_locale'])
def csv_out(request, format='csv'): context = {} # HACK: creates a dependency on contacts # TODO - add a check for contacts app activated and fix if request.user.has_perm('contacts.can_view'): #if request.user.is_authenticated(): return export(OutgoingMessage.objects.all()) return export(OutgoingMessage.objects.all(), ['id','text','backend','domains','sent'])
def export_village_membership(request, pk, format='csv'): village = Village.objects.get(id=pk) members = village.flatten(klass=Contact) if request.user.has_perm('contacts.can_view'): return export(members, ['first_seen', 'given_name', 'family_name', 'common_name', 'reporter.alias', 'gender', 'age_months', '_locale']) return export(members, ['first_seen', 'gender', 'age_months', '_locale'])
def csv_entries(req, format="csv"): context = {} if req.user.is_authenticated(): return export(SurveyEntry.objects.all()) return export( SurveyEntry.objects.all(), [ "Survey Date", "Interviewer ID", "Cluster ID", "Child ID", "Household ID", "Sex", "Date of Birth", "Age", "Height", "Weight", "Oedema", "MUAC", ], )
def csv_transfers(req, format="csv"): return export(AirtimeTransfer.objects.all())
def export_village_history(request, pk, format='csv'): village = Village.objects.get(id=pk) history = MembershipLog.objects.filter(village=village) if request.user.is_authenticated(): return export(history, ['id','date','node','action']) return export(history, ['id','date','action'])
def csv_purchases(req, format='csv'): return export(AirtimeBundlePurchase.objects.all())
def export_village_history(request, pk, format='csv'): village = Village.objects.get(id=pk) history = MembershipLog.objects.filter(village=village) if request.user.has_perm('contacts.can_view'): return export(history, ['id','date','contact','action']) return export(history, ['id','date','action'])
def csv_out(req, format='csv'): context = {} if req.user.is_authenticated(): return export(OutgoingMessage.objects.all()) return export(OutgoingMessage.objects.all(), ['id','text','backend','domain','sent'])
def csv_in(req, format='csv'): context = {} if req.user.is_authenticated(): return export(IncomingMessage.objects.all()) return export(IncomingMessage.objects.all(), ['id','text','backend','domain','received'])
def csv_transfers(req, format='csv'): return export(AirtimeTransfer.objects.all())