We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Submissions should link directly to the user that submitted
Submissions don't link directly to the user in team mode which means you need to search to see what user submitted for a given team.



--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `CTFd/constants/config.py`
Content:
```
1 import json
2 
3 from flask import url_for
4 
5 from CTFd.constants import JinjaEnum, RawEnum
6 from CTFd.utils import get_config
7 
8 
9 class ConfigTypes(str, RawEnum):
10     CHALLENGE_VISIBILITY = "challenge_visibility"
11     SCORE_VISIBILITY = "score_visibility"
12     ACCOUNT_VISIBILITY = "account_visibility"
13     REGISTRATION_VISIBILITY = "registration_visibility"
14 
15 
16 @JinjaEnum
17 class ChallengeVisibilityTypes(str, RawEnum):
18     PUBLIC = "public"
19     PRIVATE = "private"
20     ADMINS = "admins"
21 
22 
23 @JinjaEnum
24 class ScoreVisibilityTypes(str, RawEnum):
25     PUBLIC = "public"
26     PRIVATE = "private"
27     HIDDEN = "hidden"
28     ADMINS = "admins"
29 
30 
31 @JinjaEnum
32 class AccountVisibilityTypes(str, RawEnum):
33     PUBLIC = "public"
34     PRIVATE = "private"
35     ADMINS = "admins"
36 
37 
38 @JinjaEnum
39 class RegistrationVisibilityTypes(str, RawEnum):
40     PUBLIC = "public"
41     PRIVATE = "private"
42 
43 
44 class _ConfigsWrapper:
45     def __getattr__(self, attr):
46         return get_config(attr)
47 
48     @property
49     def ctf_name(self):
50         return get_config("ctf_name", default="CTFd")
51 
52     @property
53     def ctf_small_icon(self):
54         icon = get_config("ctf_small_icon")
55         if icon:
56             return url_for("views.files", path=icon)
57         return url_for("views.themes", path="img/favicon.ico")
58 
59     @property
60     def theme_header(self):
61         from CTFd.utils.helpers import markup
62 
63         return markup(get_config("theme_header", default=""))
64 
65     @property
66     def theme_footer(self):
67         from CTFd.utils.helpers import markup
68 
69         return markup(get_config("theme_footer", default=""))
70 
71     @property
72     def theme_settings(self):
73         return json.loads(get_config("theme_settings", default="null"))
74 
75     @property
76     def tos_or_privacy(self):
77         tos = bool(get_config("tos_url") or get_config("tos_text"))
78         privacy = bool(get_config("privacy_url") or get_config("privacy_text"))
79         return tos or privacy
80 
81     @property
82     def tos_link(self):
83         return get_config("tos_url", default=url_for("views.tos"))
84 
85     @property
86     def privacy_link(self):
87         return get_config("privacy_url", default=url_for("views.privacy"))
88 
89 
90 Configs = _ConfigsWrapper()
91
```

Path: `CTFd/utils/modes/__init__.py`
Content:
```
1 from flask import url_for
2 
3 from CTFd.models import Teams, Users
4 from CTFd.utils import get_config
5 
6 USERS_MODE = "users"
7 TEAMS_MODE = "teams"
8 
9 
10 def generate_account_url(account_id, admin=False):
11     if get_config("user_mode") == USERS_MODE:
12         if admin:
13             return url_for("admin.users_detail", user_id=account_id)
14         else:
15             return url_for("users.public", user_id=account_id)
16     elif get_config("user_mode") == TEAMS_MODE:
17         if admin:
18             return url_for("admin.teams_detail", team_id=account_id)
19         else:
20             return url_for("teams.public", team_id=account_id)
21 
22 
23 def get_model():
24     if get_config("user_mode") == USERS_MODE:
25         return Users
26     elif get_config("user_mode") == TEAMS_MODE:
27         return Teams
28 
29 
30 def get_mode_as_word(plural=False, capitalize=False):
31     if get_config("user_mode") == USERS_MODE:
32         word = "user"
33     else:
34         word = "team"
35 
36     if plural:
37         word += "s"
38     if capitalize:
39         word = word.title()
40     return word
41
```

Path: `CTFd/admin/submissions.py`
Content:
```
1 from flask import render_template, request, url_for
2 
3 from CTFd.admin import admin
4 from CTFd.models import Challenges, Submissions
5 from CTFd.utils.decorators import admins_only
6 from CTFd.utils.helpers.models import build_model_filters
7 from CTFd.utils.modes import get_model
8 
9 
10 @admin.route("/admin/submissions", defaults={"submission_type": None})
11 @admin.route("/admin/submissions/<submission_type>")
12 @admins_only
13 def submissions_listing(submission_type):
14     filters_by = {}
15     if submission_type:
16         filters_by["type"] = submission_type
17     filters = []
18 
19     q = request.args.get("q")
20     field = request.args.get("field")
21     page = abs(request.args.get("page", 1, type=int))
22 
23     filters = build_model_filters(
24         model=Submissions,
25         query=q,
26         field=field,
27         extra_columns={
28             "challenge_name": Challenges.name,
29             "account_id": Submissions.account_id,
30         },
31     )
32 
33     Model = get_model()
34 
35     submissions = (
36         Submissions.query.add_columns(
37             Submissions.id,
38             Submissions.type,
39             Submissions.challenge_id,
40             Submissions.provided,
41             Submissions.account_id,
42             Submissions.date,
43             Challenges.name.label("challenge_name"),
44             Model.name.label("account_name"),
45         )
46         .filter_by(**filters_by)
47         .filter(*filters)
48         .join(Challenges)
49         .join(Model)
50         .order_by(Submissions.date.desc())
51         .paginate(page=page, per_page=50)
52     )
53 
54     args = dict(request.args)
55     args.pop("page", 1)
56 
57     return render_template(
58         "admin/submissions.html",
59         submissions=submissions,
60         prev_page=url_for(
61             request.endpoint,
62             submission_type=submission_type,
63             page=submissions.prev_num,
64             **args
65         ),
66         next_page=url_for(
67             request.endpoint,
68             submission_type=submission_type,
69             page=submissions.next_num,
70             **args
71         ),
72         type=submission_type,
73         q=q,
74         field=field,
75     )
76
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/CTFd/admin/submissions.py b/CTFd/admin/submissions.py
--- a/CTFd/admin/submissions.py
+++ b/CTFd/admin/submissions.py
@@ -33,17 +33,7 @@
     Model = get_model()
 
     submissions = (
-        Submissions.query.add_columns(
-            Submissions.id,
-            Submissions.type,
-            Submissions.challenge_id,
-            Submissions.provided,
-            Submissions.account_id,
-            Submissions.date,
-            Challenges.name.label("challenge_name"),
-            Model.name.label("account_name"),
-        )
-        .filter_by(**filters_by)
+        Submissions.query.filter_by(**filters_by)
         .filter(*filters)
         .join(Challenges)
         .join(Model)
diff --git a/CTFd/constants/config.py b/CTFd/constants/config.py
--- a/CTFd/constants/config.py
+++ b/CTFd/constants/config.py
@@ -13,6 +13,12 @@
     REGISTRATION_VISIBILITY = "registration_visibility"
 
 
+@JinjaEnum
+class UserModeTypes(str, RawEnum):
+    USERS = "users"
+    TEAMS = "teams"
+
+
 @JinjaEnum
 class ChallengeVisibilityTypes(str, RawEnum):
     PUBLIC = "public"
diff --git a/CTFd/utils/modes/__init__.py b/CTFd/utils/modes/__init__.py
--- a/CTFd/utils/modes/__init__.py
+++ b/CTFd/utils/modes/__init__.py
@@ -3,6 +3,7 @@
 from CTFd.models import Teams, Users
 from CTFd.utils import get_config
 
+# TODO: Replace these constants with the UserModeTypes enum
 USERS_MODE = "users"
 TEAMS_MODE = "teams"

{"golden_diff": "diff --git a/CTFd/admin/submissions.py b/CTFd/admin/submissions.py\n--- a/CTFd/admin/submissions.py\n+++ b/CTFd/admin/submissions.py\n@@ -33,17 +33,7 @@\n     Model = get_model()\n \n     submissions = (\n-        Submissions.query.add_columns(\n-            Submissions.id,\n-            Submissions.type,\n-            Submissions.challenge_id,\n-            Submissions.provided,\n-            Submissions.account_id,\n-            Submissions.date,\n-            Challenges.name.label(\"challenge_name\"),\n-            Model.name.label(\"account_name\"),\n-        )\n-        .filter_by(**filters_by)\n+        Submissions.query.filter_by(**filters_by)\n         .filter(*filters)\n         .join(Challenges)\n         .join(Model)\ndiff --git a/CTFd/constants/config.py b/CTFd/constants/config.py\n--- a/CTFd/constants/config.py\n+++ b/CTFd/constants/config.py\n@@ -13,6 +13,12 @@\n     REGISTRATION_VISIBILITY = \"registration_visibility\"\n \n \n+@JinjaEnum\n+class UserModeTypes(str, RawEnum):\n+    USERS = \"users\"\n+    TEAMS = \"teams\"\n+\n+\n @JinjaEnum\n class ChallengeVisibilityTypes(str, RawEnum):\n     PUBLIC = \"public\"\ndiff --git a/CTFd/utils/modes/__init__.py b/CTFd/utils/modes/__init__.py\n--- a/CTFd/utils/modes/__init__.py\n+++ b/CTFd/utils/modes/__init__.py\n@@ -3,6 +3,7 @@\n from CTFd.models import Teams, Users\n from CTFd.utils import get_config\n \n+# TODO: Replace these constants with the UserModeTypes enum\n USERS_MODE = \"users\"\n TEAMS_MODE = \"teams\"\n", "issue": "Submissions should link directly to the user that submitted\nSubmissions don't link directly to the user in team mode which means you need to search to see what user submitted for a given team.\r\n\r\n\n", "before_files": [{"content": "import json\n\nfrom flask import url_for\n\nfrom CTFd.constants import JinjaEnum, RawEnum\nfrom CTFd.utils import get_config\n\n\nclass ConfigTypes(str, RawEnum):\n    CHALLENGE_VISIBILITY = \"challenge_visibility\"\n    SCORE_VISIBILITY = \"score_visibility\"\n    ACCOUNT_VISIBILITY = \"account_visibility\"\n    REGISTRATION_VISIBILITY = \"registration_visibility\"\n\n\n@JinjaEnum\nclass ChallengeVisibilityTypes(str, RawEnum):\n    PUBLIC = \"public\"\n    PRIVATE = \"private\"\n    ADMINS = \"admins\"\n\n\n@JinjaEnum\nclass ScoreVisibilityTypes(str, RawEnum):\n    PUBLIC = \"public\"\n    PRIVATE = \"private\"\n    HIDDEN = \"hidden\"\n    ADMINS = \"admins\"\n\n\n@JinjaEnum\nclass AccountVisibilityTypes(str, RawEnum):\n    PUBLIC = \"public\"\n    PRIVATE = \"private\"\n    ADMINS = \"admins\"\n\n\n@JinjaEnum\nclass RegistrationVisibilityTypes(str, RawEnum):\n    PUBLIC = \"public\"\n    PRIVATE = \"private\"\n\n\nclass _ConfigsWrapper:\n    def __getattr__(self, attr):\n        return get_config(attr)\n\n    @property\n    def ctf_name(self):\n        return get_config(\"ctf_name\", default=\"CTFd\")\n\n    @property\n    def ctf_small_icon(self):\n        icon = get_config(\"ctf_small_icon\")\n        if icon:\n            return url_for(\"views.files\", path=icon)\n        return url_for(\"views.themes\", path=\"img/favicon.ico\")\n\n    @property\n    def theme_header(self):\n        from CTFd.utils.helpers import markup\n\n        return markup(get_config(\"theme_header\", default=\"\"))\n\n    @property\n    def theme_footer(self):\n        from CTFd.utils.helpers import markup\n\n        return markup(get_config(\"theme_footer\", default=\"\"))\n\n    @property\n    def theme_settings(self):\n        return json.loads(get_config(\"theme_settings\", default=\"null\"))\n\n    @property\n    def tos_or_privacy(self):\n        tos = bool(get_config(\"tos_url\") or get_config(\"tos_text\"))\n        privacy = bool(get_config(\"privacy_url\") or get_config(\"privacy_text\"))\n        return tos or privacy\n\n    @property\n    def tos_link(self):\n        return get_config(\"tos_url\", default=url_for(\"views.tos\"))\n\n    @property\n    def privacy_link(self):\n        return get_config(\"privacy_url\", default=url_for(\"views.privacy\"))\n\n\nConfigs = _ConfigsWrapper()\n", "path": "CTFd/constants/config.py"}, {"content": "from flask import url_for\n\nfrom CTFd.models import Teams, Users\nfrom CTFd.utils import get_config\n\nUSERS_MODE = \"users\"\nTEAMS_MODE = \"teams\"\n\n\ndef generate_account_url(account_id, admin=False):\n    if get_config(\"user_mode\") == USERS_MODE:\n        if admin:\n            return url_for(\"admin.users_detail\", user_id=account_id)\n        else:\n            return url_for(\"users.public\", user_id=account_id)\n    elif get_config(\"user_mode\") == TEAMS_MODE:\n        if admin:\n            return url_for(\"admin.teams_detail\", team_id=account_id)\n        else:\n            return url_for(\"teams.public\", team_id=account_id)\n\n\ndef get_model():\n    if get_config(\"user_mode\") == USERS_MODE:\n        return Users\n    elif get_config(\"user_mode\") == TEAMS_MODE:\n        return Teams\n\n\ndef get_mode_as_word(plural=False, capitalize=False):\n    if get_config(\"user_mode\") == USERS_MODE:\n        word = \"user\"\n    else:\n        word = \"team\"\n\n    if plural:\n        word += \"s\"\n    if capitalize:\n        word = word.title()\n    return word\n", "path": "CTFd/utils/modes/__init__.py"}, {"content": "from flask import render_template, request, url_for\n\nfrom CTFd.admin import admin\nfrom CTFd.models import Challenges, Submissions\nfrom CTFd.utils.decorators import admins_only\nfrom CTFd.utils.helpers.models import build_model_filters\nfrom CTFd.utils.modes import get_model\n\n\n@admin.route(\"/admin/submissions\", defaults={\"submission_type\": None})\n@admin.route(\"/admin/submissions/<submission_type>\")\n@admins_only\ndef submissions_listing(submission_type):\n    filters_by = {}\n    if submission_type:\n        filters_by[\"type\"] = submission_type\n    filters = []\n\n    q = request.args.get(\"q\")\n    field = request.args.get(\"field\")\n    page = abs(request.args.get(\"page\", 1, type=int))\n\n    filters = build_model_filters(\n        model=Submissions,\n        query=q,\n        field=field,\n        extra_columns={\n            \"challenge_name\": Challenges.name,\n            \"account_id\": Submissions.account_id,\n        },\n    )\n\n    Model = get_model()\n\n    submissions = (\n        Submissions.query.add_columns(\n            Submissions.id,\n            Submissions.type,\n            Submissions.challenge_id,\n            Submissions.provided,\n            Submissions.account_id,\n            Submissions.date,\n            Challenges.name.label(\"challenge_name\"),\n            Model.name.label(\"account_name\"),\n        )\n        .filter_by(**filters_by)\n        .filter(*filters)\n        .join(Challenges)\n        .join(Model)\n        .order_by(Submissions.date.desc())\n        .paginate(page=page, per_page=50)\n    )\n\n    args = dict(request.args)\n    args.pop(\"page\", 1)\n\n    return render_template(\n        \"admin/submissions.html\",\n        submissions=submissions,\n        prev_page=url_for(\n            request.endpoint,\n            submission_type=submission_type,\n            page=submissions.prev_num,\n            **args\n        ),\n        next_page=url_for(\n            request.endpoint,\n            submission_type=submission_type,\n            page=submissions.next_num,\n            **args\n        ),\n        type=submission_type,\n        q=q,\n        field=field,\n    )\n", "path": "CTFd/admin/submissions.py"}], "after_files": [{"content": "import json\n\nfrom flask import url_for\n\nfrom CTFd.constants import JinjaEnum, RawEnum\nfrom CTFd.utils import get_config\n\n\nclass ConfigTypes(str, RawEnum):\n    CHALLENGE_VISIBILITY = \"challenge_visibility\"\n    SCORE_VISIBILITY = \"score_visibility\"\n    ACCOUNT_VISIBILITY = \"account_visibility\"\n    REGISTRATION_VISIBILITY = \"registration_visibility\"\n\n\n@JinjaEnum\nclass UserModeTypes(str, RawEnum):\n    USERS = \"users\"\n    TEAMS = \"teams\"\n\n\n@JinjaEnum\nclass ChallengeVisibilityTypes(str, RawEnum):\n    PUBLIC = \"public\"\n    PRIVATE = \"private\"\n    ADMINS = \"admins\"\n\n\n@JinjaEnum\nclass ScoreVisibilityTypes(str, RawEnum):\n    PUBLIC = \"public\"\n    PRIVATE = \"private\"\n    HIDDEN = \"hidden\"\n    ADMINS = \"admins\"\n\n\n@JinjaEnum\nclass AccountVisibilityTypes(str, RawEnum):\n    PUBLIC = \"public\"\n    PRIVATE = \"private\"\n    ADMINS = \"admins\"\n\n\n@JinjaEnum\nclass RegistrationVisibilityTypes(str, RawEnum):\n    PUBLIC = \"public\"\n    PRIVATE = \"private\"\n\n\nclass _ConfigsWrapper:\n    def __getattr__(self, attr):\n        return get_config(attr)\n\n    @property\n    def ctf_name(self):\n        return get_config(\"ctf_name\", default=\"CTFd\")\n\n    @property\n    def ctf_small_icon(self):\n        icon = get_config(\"ctf_small_icon\")\n        if icon:\n            return url_for(\"views.files\", path=icon)\n        return url_for(\"views.themes\", path=\"img/favicon.ico\")\n\n    @property\n    def theme_header(self):\n        from CTFd.utils.helpers import markup\n\n        return markup(get_config(\"theme_header\", default=\"\"))\n\n    @property\n    def theme_footer(self):\n        from CTFd.utils.helpers import markup\n\n        return markup(get_config(\"theme_footer\", default=\"\"))\n\n    @property\n    def theme_settings(self):\n        return json.loads(get_config(\"theme_settings\", default=\"null\"))\n\n    @property\n    def tos_or_privacy(self):\n        tos = bool(get_config(\"tos_url\") or get_config(\"tos_text\"))\n        privacy = bool(get_config(\"privacy_url\") or get_config(\"privacy_text\"))\n        return tos or privacy\n\n    @property\n    def tos_link(self):\n        return get_config(\"tos_url\", default=url_for(\"views.tos\"))\n\n    @property\n    def privacy_link(self):\n        return get_config(\"privacy_url\", default=url_for(\"views.privacy\"))\n\n\nConfigs = _ConfigsWrapper()\n", "path": "CTFd/constants/config.py"}, {"content": "from flask import url_for\n\nfrom CTFd.models import Teams, Users\nfrom CTFd.utils import get_config\n\n# TODO: Replace these constants with the UserModeTypes enum\nUSERS_MODE = \"users\"\nTEAMS_MODE = \"teams\"\n\n\ndef generate_account_url(account_id, admin=False):\n    if get_config(\"user_mode\") == USERS_MODE:\n        if admin:\n            return url_for(\"admin.users_detail\", user_id=account_id)\n        else:\n            return url_for(\"users.public\", user_id=account_id)\n    elif get_config(\"user_mode\") == TEAMS_MODE:\n        if admin:\n            return url_for(\"admin.teams_detail\", team_id=account_id)\n        else:\n            return url_for(\"teams.public\", team_id=account_id)\n\n\ndef get_model():\n    if get_config(\"user_mode\") == USERS_MODE:\n        return Users\n    elif get_config(\"user_mode\") == TEAMS_MODE:\n        return Teams\n\n\ndef get_mode_as_word(plural=False, capitalize=False):\n    if get_config(\"user_mode\") == USERS_MODE:\n        word = \"user\"\n    else:\n        word = \"team\"\n\n    if plural:\n        word += \"s\"\n    if capitalize:\n        word = word.title()\n    return word\n", "path": "CTFd/utils/modes/__init__.py"}, {"content": "from flask import render_template, request, url_for\n\nfrom CTFd.admin import admin\nfrom CTFd.models import Challenges, Submissions\nfrom CTFd.utils.decorators import admins_only\nfrom CTFd.utils.helpers.models import build_model_filters\nfrom CTFd.utils.modes import get_model\n\n\n@admin.route(\"/admin/submissions\", defaults={\"submission_type\": None})\n@admin.route(\"/admin/submissions/<submission_type>\")\n@admins_only\ndef submissions_listing(submission_type):\n    filters_by = {}\n    if submission_type:\n        filters_by[\"type\"] = submission_type\n    filters = []\n\n    q = request.args.get(\"q\")\n    field = request.args.get(\"field\")\n    page = abs(request.args.get(\"page\", 1, type=int))\n\n    filters = build_model_filters(\n        model=Submissions,\n        query=q,\n        field=field,\n        extra_columns={\n            \"challenge_name\": Challenges.name,\n            \"account_id\": Submissions.account_id,\n        },\n    )\n\n    Model = get_model()\n\n    submissions = (\n        Submissions.query.filter_by(**filters_by)\n        .filter(*filters)\n        .join(Challenges)\n        .join(Model)\n        .order_by(Submissions.date.desc())\n        .paginate(page=page, per_page=50)\n    )\n\n    args = dict(request.args)\n    args.pop(\"page\", 1)\n\n    return render_template(\n        \"admin/submissions.html\",\n        submissions=submissions,\n        prev_page=url_for(\n            request.endpoint,\n            submission_type=submission_type,\n            page=submissions.prev_num,\n            **args\n        ),\n        next_page=url_for(\n            request.endpoint,\n            submission_type=submission_type,\n            page=submissions.next_num,\n            **args\n        ),\n        type=submission_type,\n        q=q,\n        field=field,\n    )\n", "path": "CTFd/admin/submissions.py"}]}