Exemplo n.º 1
0
 def response_deidentified_data(domain, new_plan_version):
     """
     De-id exports will be hidden
     """
     startkey = json.dumps([domain.name, ""])[:-3]
     endkey = "%s{" % startkey
     reports = SavedExportSchema.view(
         "couchexport/saved_export_schemas",
         startkey=startkey,
         endkey=endkey,
         include_docs=True,
         reduce=False,
     )
     num_deid_reports = len(filter(lambda r: r.is_safe, reports))
     if num_deid_reports > 0:
         return _fmt_alert(
             ungettext(
                 "You have %(num)d De-Identified Export. Selecting this "
                 "plan will remove it.",
                 "You have %(num)d De-Identified Exports. Selecting this "
                 "plan will remove them.",
                 num_deid_reports
             ) % {
                 'num': num_deid_reports,
             }
         )
Exemplo n.º 2
0
 def response_deidentified_data(domain, new_plan_version):
     """
     De-id exports will be hidden
     """
     startkey = json.dumps([domain.name, ""])[:-3]
     endkey = "%s{" % startkey
     reports = SavedExportSchema.view(
         "couchexport/saved_export_schemas",
         startkey=startkey,
         endkey=endkey,
         include_docs=True,
         reduce=False,
     )
     num_deid_reports = len(filter(lambda r: r.is_safe, reports))
     if num_deid_reports > 0:
         return _fmt_alert(
             ungettext(
                 "You have %(num)d De-Identified Export. Selecting this "
                 "plan will remove it.",
                 "You have %(num)d De-Identified Exports. Selecting this "
                 "plan will remove them.",
                 num_deid_reports
             ) % {
                 'num': num_deid_reports,
             }
         )
Exemplo n.º 3
0
 def show_in_navigation(cls, domain=None, project=None, user=None):
     startkey = json.dumps([domain, ""])[:-3]
     return SavedExportSchema.view("couchexport/saved_export_schemas",
         startkey=startkey,
         limit=1,
         include_docs=False,
         stale=settings.COUCH_STALE_QUERY,
     ).count() > 0
Exemplo n.º 4
0
 def get_saved_exports(self):
     startkey = json.dumps([self.domain, ""])[:-3]
     endkey = "%s{" % startkey
     exports = SavedExportSchema.view("couchexport/saved_export_schemas",
         startkey=startkey, endkey=endkey,
         include_docs=True).all()
     exports = filter(lambda x: x.type == "case", exports)
     return exports
Exemplo n.º 5
0
 def show_in_navigation(cls, request, domain=None):
     startkey = json.dumps([domain, ""])[:-3]
     return SavedExportSchema.view("couchexport/saved_export_schemas",
         startkey=startkey,
         limit=1,
         include_docs=False,
         stale='update_after',
     ).count() > 0
Exemplo n.º 6
0
 def show_in_navigation(cls, request, *args, **kwargs):
     domain = kwargs.get("domain")
     startkey = json.dumps([domain, ""])[:-3]
     return (
         SavedExportSchema.view(
             "couchexport/saved_export_schemas", startkey=startkey, limit=1, include_docs=False
         ).all()
         > 0
     )
Exemplo n.º 7
0
    def handle(self, *args, **options):
        if len(args) != 1:
            raise CommandError("Syntax: ./manage.py migrate_export_types [default type]!")

        default_type = args[0]
        for export in SavedExportSchema.view("couchexport/saved_export_schemas", include_docs=True):
            if not export.type:
                print "migrating %s" % export
                export.type = default_type
                if not options["dryrun"]:
                    export.save()
        print "Done!"
Exemplo n.º 8
0
    def handle(self, *args, **options):
        if len(args) != 1:
            raise CommandError(
                "Syntax: ./manage.py migrate_export_types [default type]!")

        default_type = args[0]
        for export in SavedExportSchema.view(
                "couchexport/saved_export_schemas", include_docs=True):
            if not export.type:
                print "migrating %s" % export
                export.type = default_type
                if not options['dryrun']:
                    export.save()
        print "Done!"
Exemplo n.º 9
0
 def handle(self, *args, **options):
     if len(args) != 0: raise CommandError("This command doesn't expect arguments!")
         
     for export in SavedExportSchema.view("couchexport/saved_export_schemas", include_docs=True):
         print "migrating %s" % export
         assert len(export.tables) == 1, "there should only be 1 root table!"
         [table] = export.tables
         if table.index == OLD_ROOT_INDEX:
             table.index = NEW_ROOT_INDEX
             if not options["dryrun"]:
                 export.save()
             print "migrated"
         else:
             print "nothing to do"
             
Exemplo n.º 10
0
 def response_deidentified_data(self):
     """
     De-id exports will be hidden
     """
     startkey = json.dumps([self.domain.name, ""])[:-3]
     endkey = "%s{" % startkey
     num_deid_reports = SavedExportSchema.view("couchexport/saved_export_schemas",
         startkey=startkey,
         endkey=endkey,
         include_docs=False,
     ).count()
     if num_deid_reports > 0:
         return self._fmt_alert(
             ungettext(
                 "You have %(num)d De-Identified Export. Selecting this plan will remove it.",
                 "You have %(num)d De-Identified Exports. Selecting this plan will remove them.",
                 num_deid_reports
             ) % {
                 'num': num_deid_reports,
             }
         )
Exemplo n.º 11
0
 def response_deidentified_data(self):
     """
     De-id exports will be hidden
     """
     startkey = json.dumps([self.domain.name, ""])[:-3]
     endkey = "%s{" % startkey
     num_deid_reports = SavedExportSchema.view(
         "couchexport/saved_export_schemas",
         startkey=startkey,
         endkey=endkey,
         include_docs=False,
     ).count()
     if num_deid_reports > 0:
         return self._fmt_alert(
             ungettext(
                 "You have %(num)d De-Identified Export. Selecting this "
                 "plan will remove it.",
                 "You have %(num)d De-Identified Exports. Selecting this "
                 "plan will remove them.", num_deid_reports) % {
                     'num': num_deid_reports,
                 })