internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: OpenEnergyPlatform/oeplatform

Issue:
clear sanbox command doesnot remove tables in `_sandbox`



Discussion:

Resolving patch:
diff --git a/dataedit/management/commands/clear_sandbox.py b/dataedit/management/commands/clear_sandbox.py
--- a/dataedit/management/commands/clear_sandbox.py
+++ b/dataedit/management/commands/clear_sandbox.py
@@ -28,6 +28,15 @@ def get_sandbox_table_names_oedb() -> List[str]:
     return sqla.inspect(engine).get_table_names(schema=SANDBOX_SCHEMA)
 
 
+def get_sandbox_meta_table_names_oedb() -> List[str]:
+    """
+    Returns:
+        List[str]: list of table names in oedb in sandbox meta schema
+    """
+    engine = _get_engine()
+    return sqla.inspect(engine).get_table_names(schema="_" + SANDBOX_SCHEMA)
+
+
 def clear_sandbox(output: bool = False) -> None:
     """delete all tables from the sandbox schema.
 
@@ -53,6 +62,12 @@ def clear_sandbox(output: bool = False) -> None:
             print(f"oedb: {sql}")
         engine.execute(sql)
 
+    for table_name in get_sandbox_meta_table_names_oedb():
+        sql = f'DROP TABLE "_{SANDBOX_SCHEMA}"."{table_name}" CASCADE;'
+        if output:
+            print(f"oedb: {sql}")
+        engine.execute(sql)
+
     # delete all from django
     for table in get_sandbox_tables_django():
         if output:


Test patch:
diff --git a/api/tests/test_clear_sandbox.py b/api/tests/test_clear_sandbox.py
--- a/api/tests/test_clear_sandbox.py
+++ b/api/tests/test_clear_sandbox.py
@@ -1,6 +1,7 @@
 from dataedit.management.commands.clear_sandbox import (
     SANDBOX_SCHEMA,
     clear_sandbox,
+    get_sandbox_meta_table_names_oedb,
     get_sandbox_table_names_oedb,
     get_sandbox_tables_django,
 )
@@ -25,6 +26,7 @@ def test_clear_sandbox(self):
         # check that sandbox is not empty
         self.assertTrue(len(get_sandbox_tables_django()) > 0)
         self.assertTrue(len(get_sandbox_table_names_oedb()) > 0)
+        self.assertTrue(len(get_sandbox_meta_table_names_oedb()) > 0)
 
         # run the management command
         clear_sandbox()
@@ -32,3 +34,4 @@ def test_clear_sandbox(self):
         # check that sandbox is empty
         self.assertTrue(len(get_sandbox_tables_django()) == 0)
         self.assertTrue(len(get_sandbox_table_names_oedb()) == 0)
+        self.assertTrue(len(get_sandbox_meta_table_names_oedb()) == 0)
Repository: OpenEnergyPlatform/oeplatform

Issue:
Improve reading of version file in Welcome View
* use caching because file is read every time user requests main page
* wrap in try-except (missing release notice should not break the main page)


FYI: @jh-RLI 


Discussion:

Resolving patch:
diff --git a/base/views.py b/base/views.py
--- a/base/views.py
+++ b/base/views.py
@@ -1,6 +1,7 @@
 import json
 import os
 import re
+from functools import lru_cache
 
 import markdown2
 from django.core.mail import send_mail
@@ -21,11 +22,24 @@
 SITE_ROOT = os.path.dirname(os.path.realpath(__file__))
 
 
-class Welcome(View):
-    def get(self, request):
-        os.path.dirname(os.path.realpath(__file__))
-        version_expr = r"^(?P<major>\d+)\.(?P<minor>\d+)+\.(?P<patch>\d+)$"
-        markdowner = markdown2.Markdown()
+@lru_cache(maxsize=None)
+def read_version_changes():
+    """read version and changes from changelog markdown
+
+    We use cache so it can stay in process memory and we dont have to read files
+    in every request. this only changes on a new release anyway, in which case
+    the process is restarted.
+
+    Returns:
+       dict: {"version": (major, minor, patch), "changes": changes}
+    """
+    os.path.dirname(os.path.realpath(__file__))
+    version_expr = r"^(?P<major>\d+)\.(?P<minor>\d+)+\.(?P<patch>\d+)$"
+    markdowner = markdown2.Markdown()
+    import logging
+
+    logging.error("READING")
+    try:
         with open(os.path.join(SITE_ROOT, "..", "VERSION")) as version_file:
             match = re.match(version_expr, version_file.read())
             major, minor, patch = match.groups()
@@ -39,11 +53,16 @@ def get(self, request):
             changes = markdowner.convert(
                 "\n".join(line for line in change_file.readlines())
             )
-        return render(
-            request,
-            "base/index.html",
-            {"version": "%s.%s.%s" % (major, minor, patch), "changes": changes},
-        )
+    except Exception:
+        # probably because change_file is missing
+        major, minor, patch, changes = "", "", "", ""
+    return {"version": (major, minor, patch), "changes": changes}
+
+
+class Welcome(View):
+    def get(self, request):
+        context = read_version_changes()
+        return render(request, "base/index.html", context)
 
 
 def get_logs(request):


Test patch:
Repository: OpenEnergyPlatform/oeplatform

Issue:
[OPR] Begin feature rollout phase - Communicate to the use
## Description of the issue

The open peer review process is about to be rolled out to the open energy plaform. As we first release the feature into the wild, we must communicate that we start the first step of the rollout phase. This phase is expected to be error prone and the users must be guided to a github discussion where they can share thier experiences openly. 

## Ideas of solution

Display information on the rollout pahse in the reviewer and contpributor pages. 
Draft:
"This feature is in early rollout phase now. We do expect you to experience some errors. Please share your experience in this [discussion]() on github (login required)."

## Workflow checklist
- [x] I am aware of the workflow in [CONTRIBUTING.md](https://github.com/OpenEnergyPlatform/oeplatform/blob/develop/CONTRIBUTING.md)



Discussion:

Resolving patch:
diff --git a/login/views.py b/login/views.py
--- a/login/views.py
+++ b/login/views.py
@@ -65,6 +65,7 @@ def get(self, request, user_id):
             reviewer_user=user
         )
         latest_review = peer_review_reviews.last()
+        # print(latest_review)
         if latest_review is not None:
             review_history = peer_review_reviews.exclude(pk=latest_review.pk)
             current_manager = PeerReviewManager.load(latest_review)


Test patch:
Repository: OpenEnergyPlatform/oeplatform

Issue:
Include the Open Energy Compendium in the navigation bar
## Description of the issue

A first version of the **Open Energy Compendium** is ready for integration.

## Ideas of solution

Link under `About` / `Compendium`

## Workflow checklist
- [x] I am aware of the workflow in [CONTRIBUTING.md](https://github.com/OpenEnergyPlatform/oeplatform/blob/develop/CONTRIBUTING.md)



Discussion:

Resolving patch:
diff --git a/oeplatform/settings.py b/oeplatform/settings.py
--- a/oeplatform/settings.py
+++ b/oeplatform/settings.py
@@ -81,6 +81,7 @@
     "tutorials_licenses": "https://openenergyplatform.github.io/academy/tutorials/metadata/tutorial_open-data-licenses/",
     # noqa E501
     "readthedocs": "https://oeplatform.readthedocs.io/en/latest/?badge=latest",
+    "compendium": "https://openenergyplatform.github.io/organisation/",
 }
 
 


Test patch:
Repository: OpenEnergyPlatform/oeplatform

Issue:
[OPR] Enable submit button in review page if all fields are reviewed
## Description of the issue
Currently the submit button can be clicked at any time. This is not the desired state. The submit button for both (reviewer and contributor) should remain disabled unital all fields are reviewed.

On the reviewer page, the field state must either be:
- accepted
- suggestion
- rejected

On contributor page, the state must be:
- accepted
- rejected

## Ideas of solution

- implement check review complete JavaScript function


## Workflow checklist
- [x] I am aware of the workflow in [CONTRIBUTING.md](https://github.com/OpenEnergyPlatform/oeplatform/blob/develop/CONTRIBUTING.md)



Discussion:

Resolving patch:
diff --git a/dataedit/models.py b/dataedit/models.py
--- a/dataedit/models.py
+++ b/dataedit/models.py
@@ -404,6 +404,28 @@ def filter_opr_by_contributor(contributor_user):
             review_id__status=ReviewDataStatus.SAVED.value
         )
     
+    # @staticmethod
+    # def get_last_open_peer_review(contributor_user):
+    #     """
+    #     Get the last open peer review for the given contributor.
+
+    #     Args:
+    #         contributor_user (User): The contributor user.
+
+    #     Returns:
+    #         PeerReview: Last open peer review or None if not found.
+    #     """
+    #     try:
+    #         return PeerReview.objects.filter(
+    #             contributor=contributor_user,
+    #             is_finished=False
+    #         ).exclude(
+    #             review_id__current_reviewer=Reviewer.REVIEWER.value,
+    #             review_id__status=ReviewDataStatus.SAVED.value
+    #         ).latest('date_started')
+    #     except PeerReview.DoesNotExist:
+    #         return None
+        
     @staticmethod
     def filter_opr_by_table(schema, table):
         """


Test patch:
Repository: OpenEnergyPlatform/oeplatform

Issue:
[OPR] Implement review page to view the review result details after the review is finished
## Description of the issue



## Ideas of solution

- Adapt reviewer page and hide the controles if review is finished (all button but quit and all input fields)

## Workflow checklist
- [ ] I am aware of the workflow in [CONTRIBUTING.md](https://github.com/OpenEnergyPlatform/oeplatform/blob/develop/CONTRIBUTING.md)



Discussion:

Resolving patch:
diff --git a/dataedit/views.py b/dataedit/views.py
--- a/dataedit/views.py
+++ b/dataedit/views.py
@@ -2008,6 +2008,7 @@ def get(self, request, schema, table, review_id=None):
             )
             # existing_review={}
             state_dict=None
+            review_finished=None
 
         config_data = {
             "can_add": can_add,
@@ -2015,6 +2016,7 @@ def get(self, request, schema, table, review_id=None):
             "url_table": reverse("view", kwargs={"schema": schema, "table": table}),
             "topic": schema,
             "table": table,
+            "review_finished": review_finished,
         }
 
         context_meta = {
@@ -2023,7 +2025,7 @@ def get(self, request, schema, table, review_id=None):
             "meta": metadata,
             "json_schema": json_schema,
             "field_descriptions_json": json.dumps(field_descriptions),
-            "state_dict": json.dumps(state_dict),
+            "state_dict": json.dumps(state_dict), 
         }
         return render(request, 'dataedit/opr_review.html', context=context_meta)
 


Test patch:
Repository: OpenEnergyPlatform/oeplatform

Issue:
Password reset form is not captcha protected
## Description of the issue

Every form that cause communications between the platform and the outside world should be captcha protected. Otherwise, the OEP may be used for DDOS attacks on other servers.

## Ideas of solution

Add captcha protection or similar to the password reset form

## Workflow checklist
- [x] I am aware of the workflow in [CONTRIBUTING.md](https://github.com/OpenEnergyPlatform/oeplatform/blob/develop/CONTRIBUTING.md)



Discussion:

Resolving patch:
diff --git a/login/forms.py b/login/forms.py
--- a/login/forms.py
+++ b/login/forms.py
@@ -1,7 +1,7 @@
 from captcha.fields import CaptchaField
 from django import forms
 from django.contrib.admin.widgets import FilteredSelectMultiple
-from django.contrib.auth.forms import SetPasswordForm, UserChangeForm, UserCreationForm
+from django.contrib.auth.forms import SetPasswordForm, UserChangeForm, UserCreationForm, PasswordChangeForm
 from django.core.exceptions import ValidationError
 
 from .models import UserGroup
@@ -102,6 +102,10 @@ def save(self, commit=True):
             self.user.send_activation_mail()
 
 
+class OEPPasswordChangeForm(PasswordChangeForm):
+    captcha = CaptchaField()
+
+
 class ChangeEmailForm(forms.Form):
     email = forms.EmailField()
 
diff --git a/login/views.py b/login/views.py
--- a/login/views.py
+++ b/login/views.py
@@ -12,7 +12,7 @@
 import login.models as models
 from dataedit.models import Table, PeerReviewManager
 
-from .forms import ChangeEmailForm, CreateUserForm, DetachForm, EditUserForm, GroupForm
+from .forms import ChangeEmailForm, CreateUserForm, DetachForm, EditUserForm, GroupForm, OEPPasswordChangeForm
 from .models import ADMIN_PERM, GroupMembership, UserGroup
 from .models import myuser as OepUser
 
@@ -410,6 +410,7 @@ def post(self, request):
 class OEPPasswordChangeView(PasswordChangeView):
     template_name = "login/generic_form.html"
     success_url = "/"
+    form_class = OEPPasswordChangeForm
 
 
 class AccountDeleteView(LoginRequiredMixin, DeleteView):


Test patch:
Repository: OpenEnergyPlatform/oeplatform

Issue:
[OPR] If all fields are accepted the submit button stays deactivated on the Contributor page
## Description of the issue

The contributor user cant continue the review if all fields are already accepted. 

## Steps to Reproduce
1. Start peer review and accept all fields.
2. Submit
3. Open peer review as contributor.
4. Submit button is deactivated. 

## Ideas of solution

Option 1 (preferred): immediately show the award badge widget once all fields are accepted on the reviewer page.

Option 2: Modify check to automatically activate submit button if all fields are accepted.

## Context and Environment
* Version used: 
* Operating system: 
* Environment setup and (python) version: 

## Workflow checklist
- [ ] I am aware of the workflow in [CONTRIBUTING.md](https://github.com/OpenEnergyPlatform/oeplatform/blob/develop/CONTRIBUTING.md)



Discussion:

Resolving patch:
diff --git a/dataedit/views.py b/dataedit/views.py
--- a/dataedit/views.py
+++ b/dataedit/views.py
@@ -1920,6 +1920,33 @@ def parse_keys(self, val, old=""):
         return lines
 
     def sort_in_category(self, schema, table):
+        """
+        Sorts the metadata of a table into categories and adds the value
+        suggestion and comment that were added during the review, to facilitate 
+        Further processing easier.
+
+        Note:
+        The categories spatial & temporal are often combined during visualization.
+
+        >>> Example return:
+            {
+                "general": [
+                    {
+                    "field": "id",
+                    "value": "http: //127.0.0.1:8000/dataedit/view/model_draft/test2",
+                    "reviewer_suggestion": "",
+                    "suggestion_comment": ""
+                    }
+                ],
+                "spatial": [...],
+                "temporal": [...],
+                "source": [...],
+                "license": [...],
+                "contributor": [...],
+                "resource": [...]
+            }
+        """
+        
         metadata = self.load_json(schema, table)
         val = self.parse_keys(metadata)
         gen_key_list = []
@@ -1970,6 +1997,13 @@ def sort_in_category(self, schema, table):
         return meta
 
     def get_all_field_descriptions(self, json_schema, prefix=""):
+        """
+        Collects the field title, descriptions, examples and badge information 
+        for each field of the oemetadata from the json schema and prepares them 
+        so that the values can be easily processed or used. Used to populate 
+        the reviewer box.
+        """
+        
         field_descriptions = {}
 
         def extract_descriptions(properties, prefix=""):


Test patch:
Repository: OpenEnergyPlatform/oeplatform

Issue:
Inconvenience of client cache update upon releasing/deploy new versions
## Description of the issue

When deploying a new version of an application, users are inconvenienced as they need to manually refresh the client cache to see the latest changes.

## Ideas of solution

ChatGPT suggested to introduce a Cache Busting Mechanism. We could use this existing lib [django-compressor](https://github.com/django-compressor/django-compressor).

> To set up a cache-busting mechanism in your Django application, you can use the Django extension module "django-compressor". Django Compressor allows you to compress static resources such as CSS and JavaScript files and assign them a unique hash value based on their content. This automatically changes the URL of the resources whenever they are modified.

## Workflow checklist
- [x] I am aware of the workflow in [CONTRIBUTING.md](https://github.com/OpenEnergyPlatform/oeplatform/blob/develop/CONTRIBUTING.md)



Discussion:
Suggested implementation:

Hier ist eine Schritt-für-Schritt-Anleitung, wie Sie Django Compressor einrichten können:

Installieren Sie django-compressor mit pip:

`pip install django-compressor`

Fügen Sie 'compressor' zu Ihrer INSTALLED_APPS-Liste in den Einstellungen Ihrer Django-Anwendung hinzu.

Konfigurieren Sie die Einstellungen für django-compressor in den Einstellungen Ihrer Django-Anwendung. Fügen Sie Folgendes hinzu:

```python
COMPRESS_ENABLED = True
COMPRESS_OFFLINE = True
```

Führen Sie den Befehl django manage.py collectstatic aus, um Ihre statischen Dateien zu sammeln und in den angegebenen STATIC_ROOT-Ordner zu kopieren.

Verwenden Sie den {% compress %}-Template-Tag in Ihren HTML-Templates, um die komprimierten Versionen Ihrer CSS- und JavaScript-Dateien einzufügen. Zum Beispiel:

```django
{% load compress %}

{% compress css %}
<link rel="stylesheet" href="{% static 'css/styles.css' %}">
{% endcompress %}

{% compress js %}
<script src="{% static 'js/script.js' %}"></script>
{% endcompress %}
```
@wingechr what do you think?

i think that's a very good solution.

Resolving patch:
diff --git a/oeplatform/settings.py b/oeplatform/settings.py
--- a/oeplatform/settings.py
+++ b/oeplatform/settings.py
@@ -56,6 +56,7 @@
     "fontawesome_5",
     "django_better_admin_arrayfield",
     "oeo_viewer",
+    "compressor",
 )
 
 MIDDLEWARE = (
@@ -159,3 +160,12 @@ def external_urls_context_processor(request):
 ]
 
 DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
+
+STATICFILES_FINDERS = {
+    'django.contrib.staticfiles.finders.FileSystemFinder',
+    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
+    'compressor.finders.CompressorFinder',
+}
+
+COMPRESS_ENABLED = True
+COMPRESS_OFFLINE = True


Test patch:
Repository: OpenEnergyPlatform/oeplatform

Issue:
[OPR] Reviews without any change requests can't be finalized (award badge)
## Description of the issue

Reviews without any change requests like (suggestion, deny - all fields are accepted) can't be finalized by awarding a badge. 



## Steps to Reproduce
1. Start open peer review
2. Accept all metadata fields as part of the review.
3. Finish the review by awarding a badge.

## Ideas of solution

- Create the review even if the submit button was never pressed
- Extend the functionality related to the finish / award badge button.

## Context and Environment
* Version used: oeplatform v0.14.1

## Workflow checklist
- [ ] I am aware of the workflow in [CONTRIBUTING.md](https://github.com/OpenEnergyPlatform/oeplatform/blob/develop/CONTRIBUTING.md)



Discussion:

Resolving patch:
diff --git a/dataedit/models.py b/dataedit/models.py
--- a/dataedit/models.py
+++ b/dataedit/models.py
@@ -165,6 +165,14 @@ def save(self, *args, **kwargs):
                 pm_new = PeerReviewManager(opr=self,  status=ReviewDataStatus.SUBMITTED.value)
                 pm_new.set_next_reviewer()
 
+            elif review_type == "finished":
+                # TODO: fails if the review is completed without submitting (finish in one run)
+                pm_new = PeerReviewManager(opr=self,  status=ReviewDataStatus.FINISHED.value)
+                self.is_finished = True
+                self.date_finished = timezone.now()
+                # Call the parent class's save method to save the PeerReview instance
+                super().save(*args, **kwargs)
+
             pm_new.save() 
 
             # if prev_review is not None:
@@ -179,6 +187,7 @@ def update(self, *args, **kwargs):
         Update the peer review if the latest peer review is not finished yet but either saved or submitted.
 
         """
+
         review_type = kwargs.pop('review_type', None)
         if not self.contributor == self.reviewer:
             current_pm = PeerReviewManager.load(opr=self)
diff --git a/dataedit/views.py b/dataedit/views.py
--- a/dataedit/views.py
+++ b/dataedit/views.py
@@ -2107,14 +2107,11 @@ def post(self, request, schema, table, review_id=None):
 
         Missing parts:
         - once the opr is finished (all field reviews agreed on)
-            - set the review to finished
             - merge field review results to metadata on table
             - awarde a badge
                 - is field filled in?
                 - calculate the badge by comparing filled fields
                   and the badges form metadata schema
-            - update indicator on table view (this table was succesuflly reviewed)
-            - ...
         """
         context = {}
         if request.method == "POST":


Test patch:
Repository: OpenEnergyPlatform/oeplatform

Issue:
Django compressor seems to produce unexpected cache behavior.
## Description of the issue

@Darynarli and myself experienced unexpected behavior that is triggered by the new package `django-compression`. This behavior prevents updating the compressed sources like js or css files entirely. This also happens somewhat silent, because the compressed files (e.g. `static/CACHE/js/....`) are created as expected (Using the management command `manage.py compress`). The first error can be found if the template that imports the source script (html-template) code is inspected using the dev-tool (e.g. chrome).

It was observed in the local dev-environments, production might also be affected by the next release. 

If you want to know what is part of the compression search in templates for this templatetag:
``` jinja2
{% compress js %}
  <script src="update source name here "></script>
{% endcompress %}
```

To avoid this behavior in development, you can deactivate the compressor in the settings.py 

COMPRESS_ENABLED = False

## Steps to Reproduce
We noticed this during the development of the open peer review. We have updated the source code of a JS source that is part of the compression. I noticed that the script import of the compressed file (name like output18471749.js) is not updated in the html-template after a new compressed file was created.


## Ideas of solution

- Fix django-compressor settings 
- or Report bug
- or Fix template inheritance
- other???

## Context and Environment
* Version used: 
* Operating system: 
* Environment setup and (python) version: 

## Workflow checklist
- [ ] I am aware of the workflow in [CONTRIBUTING.md](https://github.com/OpenEnergyPlatform/oeplatform/blob/develop/CONTRIBUTING.md)



Discussion:

Resolving patch:
diff --git a/oeplatform/settings.py b/oeplatform/settings.py
--- a/oeplatform/settings.py
+++ b/oeplatform/settings.py
@@ -166,5 +166,9 @@ def external_urls_context_processor(request):
     "compressor.finders.CompressorFinder",
 }
 
+
+# https://django-compressor.readthedocs.io/en/stable/settings.html
 COMPRESS_ENABLED = True
 COMPRESS_OFFLINE = True
+COMPRESS_REBUILD_TIMEOUT = 0
+COMPRESS_MTIME_DELAY = 0


Test patch:
Repository: OpenEnergyPlatform/oeplatform

Issue:
Version in CITATION.cff is out of date
## Description of the issue

We have introduced the citation.cff file, which also contains a version. This should be updated every time a release is made. It would be great if the version could be imported automatically from the VERSION file so we don't have to maintain multiple version identifiers.

## Ideas of solution

  - [x] add note to RELEASE_PROCEDURE.md (see #1228)
  - [x] auto import a version update from the VERSION file

## Context and Environment
* Version used: 
* Operating system: 
* Environment setup and (python) version: 

## Workflow checklist
- [x] I am aware of the workflow in [CONTRIBUTING.md](https://github.com/OpenEnergyPlatform/oeplatform/blob/develop/CONTRIBUTING.md)



Discussion:

Resolving patch:
diff --git a/oeplatform/__init__.py b/oeplatform/__init__.py
--- a/oeplatform/__init__.py
+++ b/oeplatform/__init__.py
@@ -0,0 +1 @@
+__version__ = "0.14.1"


Test patch: