anon-iclr-submission/benchname-bug-localization huggingface dataset:
Repository: thegreenwebfoundation/admin-portal
Issue: [BUG] Close up create path for Green IP and Green ASN

From March 22nd, it has been possible to add Green IPs and Green ASNs through the root of the admin, by passing the approval step, even if you are not a member of staff.

This change removes the ability for user who are not members of staff.

Changed files:
apps/greencheck/admin.py

diff --git a/apps/greencheck/admin.py b/apps/greencheck/admin.py
index c9585f7..bb9e6f6 100644
--- a/apps/greencheck/admin.py
+++ b/apps/greencheck/admin.py
@@ -441,13 +441,33 @@ class GreenASNAdmin(admin.ModelAdmin):
         "active",
         "asn",
         "hostingprovider",
+        "created",
+        "modified",
     ]
     search_fields = ["asn", "hostingprovider__name"]
-    fields = [
-        "active",
-        "asn",
-        "hostingprovider",
-    ]
+    fields = ["active", "asn", "hostingprovider", "created", "modified"]
+    readonly_fields = ["created", "modified"]
+
+    def has_view_permission(self, request, obj=None):
+        """
+        Only allow staff to view AS numbers via the main django
+        listing. We restrict this, to avoid end users seeing the list of
+        other providers in the admin.
+        """
+        if request.user.is_admin:
+            return True
+        return False
+
+    def has_add_permission(self, request):
+        """
+        We only allow staff to add AS numbers via the main django
+        listing.
+        Non-staff users need to use the hosting profile change view
+        page instead.
+        """
+        if request.user.is_admin:
+            return True
+        return False
 
     def get_queryset(self, request):
         qs = super().get_queryset(request)
@@ -473,18 +493,34 @@ class GreenIPAdmin(admin.ModelAdmin):
         "ip_start",
         "ip_end",
         "hostingprovider",
+        "created",
+        "modified",
     ]
     search_fields = [
         "hostingprovider__name",
         "ip_start",
         "ip_end",
     ]
-    fields = [
-        "active",
-        "ip_start",
-        "ip_end",
-        "hostingprovider",
-    ]
+    fields = ["active", "ip_start", "ip_end", "hostingprovider", "created", "modified"]
+    readonly_fields = ["created", "modified"]
+
+    def has_view_permission(self, request, obj=None):
+        """
+        Only allow staff to view AS numbers via the main django
+        listing. We restrict this, to avoid end users seeing the list of
+        other providers in the admin.
+        """
+        if request.user.is_admin:
+            return True
+        return False
+
+    def has_add_permission(self, request):
+        """
+        Like ASNs, only staff should be able to add IP ranges directly
+        """
+        if request.user.is_admin:
+            return True
+        return False
 
     def get_queryset(self, request):
         qs = super().get_queryset(request)
Repository: vortechsa/python-sdk
Issue: CargoMovementsResult.to_df('all') blows up

`            CargoMovements()
            .search(
                filter_activity="loading_state",
                filter_products="6f11b0724c9a4e85ffa7f1445bc768f054af755a090118dcf99f14745c261653",
                filter_time_min=datetime(2019, 8, 29),
                filter_time_max=datetime(2019, 8, 29, 0, 10),
            )
            .to_df(columns="all")
`

Throws exception

Changed files:
tests/endpoints/test_cargo_movements_real.py, tests/endpoints/test_vessel_movements_real.py, vortexasdk/endpoints/cargo_movements_result.py

diff --git a/tests/endpoints/test_cargo_movements_real.py b/tests/endpoints/test_cargo_movements_real.py
index 1fa2079..b910f06 100644
--- a/tests/endpoints/test_cargo_movements_real.py
+++ b/tests/endpoints/test_cargo_movements_real.py
@@ -46,6 +46,21 @@ class TestCargoMovementsReal(TestCaseUsingRealAPI):
 
         assert len(df) == 2
 
+    def test_to_df_all_columns(self):
+        df = (
+            CargoMovements()
+            .search(
+                filter_activity="loading_state",
+                filter_products="6f11b0724c9a4e85ffa7f1445bc768f054af755a090118dcf99f14745c261653",
+                filter_time_min=datetime(2019, 8, 29),
+                filter_time_max=datetime(2019, 8, 29, 0, 10),
+            )
+            .to_df(columns="all")
+            .head(2)
+        )
+
+        assert len(df) == 2
+
     def test_search_single_filter_origin_name(self):
         df = (
             CargoMovements()
diff --git a/tests/endpoints/test_vessel_movements_real.py b/tests/endpoints/test_vessel_movements_real.py
index 64b2c90..7a0a376 100644
--- a/tests/endpoints/test_vessel_movements_real.py
+++ b/tests/endpoints/test_vessel_movements_real.py
@@ -15,6 +15,20 @@ class TestVesselMovementsReal(TestCaseUsingRealAPI):
 
         assert len(v) > 10
 
+    def test_to_df_all_columns(self):
+        df = (
+            VesselMovements()
+            .search(
+                filter_time_min=datetime(2017, 10, 1, 0, 0),
+                filter_time_max=datetime(2017, 10, 1, 0, 10),
+                filter_origins="rotterdam",
+            )
+            .to_df(columns="all")
+            .head(2)
+        )
+
+        assert len(df) == 2
+
     def test_search_to_dataframe(self):
         df = (
             VesselMovements()
diff --git a/vortexasdk/endpoints/cargo_movements_result.py b/vortexasdk/endpoints/cargo_movements_result.py
index 179695c..73dccff 100644
--- a/vortexasdk/endpoints/cargo_movements_result.py
+++ b/vortexasdk/endpoints/cargo_movements_result.py
@@ -543,7 +543,10 @@ class CargoMovementsResult(Result):
         with Pool(os.cpu_count()) as pool:
             records = pool.map(flatten, super().to_list())
 
-        return pd.DataFrame(data=records, columns=columns)
+        if columns == "all":
+            return pd.DataFrame(data=records)
+        else:
+            return pd.DataFrame(data=records, columns=columns)
 
 
 DEFAULT_COLUMNS = [