瀏覽代碼

Adaptions to changed simplified user profile additions in users module

master
Dirk Alders 1 月之前
父節點
當前提交
7ff8071be9
共有 7 個檔案被更改,包括 80 行新增64 行删除
  1. 0
    4
      __init__.py
  2. 0
    16
      context.py
  3. 6
    2
      forms.py
  4. 71
    0
      migrations/0014_alter_historicalcomment_options_and_more.py
  5. 1
    1
      models.py
  6. 0
    1
      urls.py
  7. 2
    40
      views.py

+ 0
- 4
__init__.py 查看文件

@@ -21,10 +21,6 @@ def url_tasklist(request, user_filter_id=None, search_txt=None, common_filter_id
21 21
         return reverse('patt-tasklist')
22 22
 
23 23
 
24
-def url_profile(request):
25
-    return reverse('patt-profile')
26
-
27
-
28 24
 def url_projectlist(request):
29 25
     return reverse('patt-projectlist')
30 26
 

+ 0
- 16
context.py 查看文件

@@ -49,7 +49,6 @@ def navigationbar(context, request, caller_name, **kwargs):
49 49
 def menubar(context, request, caller_name, **kwargs):
50 50
     bar = context[context.MENUBAR]
51 51
     menubar_users(bar, request)
52
-    replace_profile(request, bar)
53 52
     add_help_menu(request, bar)
54 53
     add_tasklist_menu(request, bar)
55 54
     add_filter_submenu(request, bar, VIEW_TASKLIST_UID)
@@ -83,21 +82,6 @@ def finalise_bar(request, bar):
83 82
         bar.append_entry(*empty_entry_parameters(request))
84 83
 
85 84
 
86
-def replace_profile(request, bar):
87
-    try:
88
-        bar.replace_entry(
89
-            PROFILE_ENTRY_UID,
90
-            PROFILE_ENTRY_UID,                          # uid
91
-            request.user.username,                      # name
92
-            color_icon_url(request, 'user.png'),        # icon
93
-            patt.url_profile(request),                  # url
94
-            False,                                      # left
95
-            False                                       # active
96
-        )
97
-    except ValueError:
98
-        pass        # Profile entry does not exist, so exchange is not needed (e.g. no user is logged in)
99
-
100
-
101 85
 def add_help_menu(request, bar):
102 86
     bar.append_entry(
103 87
         HELP_UID,                                   # uid

+ 6
- 2
forms.py 查看文件

@@ -2,7 +2,7 @@ from django import forms
2 2
 from django.contrib.auth.models import User
3 3
 from django.db.models import Q
4 4
 from django.utils.translation import gettext as _
5
-from .models import Task, Project, Comment, Search, TASKSTATE_CHOICES, PROJECTSTATE_OPEN, ModelList, PattUserProfile
5
+from .models import Task, Project, Comment, Search, TASKSTATE_CHOICES, PROJECTSTATE_OPEN, ModelList, PattUserProfile, get_pattuserprofile
6 6
 from .search import INDEX_STATES
7 7
 
8 8
 
@@ -14,7 +14,11 @@ class PattUserProfileForm(forms.ModelForm):
14 14
             'threshold_very_soon': _('Period to targetdate for warning Group "very soon"'),
15 15
             'threshold_soon': _('Period to targetdate for warning Group "soon"'),
16 16
         }
17
-
17
+    def __init__(self, request):
18
+        if request.POST:
19
+            super().__init__(data=request.POST, instance=get_pattuserprofile(request.user))
20
+        else:
21
+            super().__init__(instance=get_pattuserprofile(request.user))
18 22
 
19 23
 class TaskForm(forms.ModelForm):
20 24
 

+ 71
- 0
migrations/0014_alter_historicalcomment_options_and_more.py 查看文件

@@ -0,0 +1,71 @@
1
+# Generated by Django 5.1.2 on 2024-11-01 19:29
2
+
3
+from django.db import migrations, models
4
+
5
+
6
+class Migration(migrations.Migration):
7
+
8
+    dependencies = [
9
+        ('patt', '0013_auto_20210117_1332'),
10
+    ]
11
+
12
+    operations = [
13
+        migrations.AlterModelOptions(
14
+            name='historicalcomment',
15
+            options={'get_latest_by': ('history_date', 'history_id'), 'ordering': ('-history_date', '-history_id'), 'verbose_name': 'historical comment', 'verbose_name_plural': 'historical comments'},
16
+        ),
17
+        migrations.AlterModelOptions(
18
+            name='historicaltask',
19
+            options={'get_latest_by': ('history_date', 'history_id'), 'ordering': ('-history_date', '-history_id'), 'verbose_name': 'historical task', 'verbose_name_plural': 'historical tasks'},
20
+        ),
21
+        migrations.AlterField(
22
+            model_name='comment',
23
+            name='id',
24
+            field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
25
+        ),
26
+        migrations.AlterField(
27
+            model_name='historicalcomment',
28
+            name='history_date',
29
+            field=models.DateTimeField(db_index=True),
30
+        ),
31
+        migrations.AlterField(
32
+            model_name='historicalcomment',
33
+            name='id',
34
+            field=models.BigIntegerField(auto_created=True, blank=True, db_index=True, verbose_name='ID'),
35
+        ),
36
+        migrations.AlterField(
37
+            model_name='historicaltask',
38
+            name='history_date',
39
+            field=models.DateTimeField(db_index=True),
40
+        ),
41
+        migrations.AlterField(
42
+            model_name='historicaltask',
43
+            name='id',
44
+            field=models.BigIntegerField(auto_created=True, blank=True, db_index=True, verbose_name='ID'),
45
+        ),
46
+        migrations.AlterField(
47
+            model_name='pattuserprofile',
48
+            name='id',
49
+            field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
50
+        ),
51
+        migrations.AlterField(
52
+            model_name='pattuserprofile',
53
+            name='threshold_soon',
54
+            field=models.IntegerField(choices=[(1, '1 day'), (2, '2 days'), (3, '3 days'), (5, '5 days'), (7, '7 days'), (10, '10 days'), (14, '14 days'), (21, ' 21 days')], default=10),
55
+        ),
56
+        migrations.AlterField(
57
+            model_name='project',
58
+            name='id',
59
+            field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
60
+        ),
61
+        migrations.AlterField(
62
+            model_name='search',
63
+            name='id',
64
+            field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
65
+        ),
66
+        migrations.AlterField(
67
+            model_name='task',
68
+            name='id',
69
+            field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
70
+        ),
71
+    ]

+ 1
- 1
models.py 查看文件

@@ -6,7 +6,7 @@ from simple_history.models import HistoricalRecords
6 6
 
7 7
 
8 8
 THRESHOLD_VERY_SOON_CHOICES = ((1, '1 day'), (2, '2 days'), (3, '3 days'), (4, '4 days'), (5, '5 days'), (7, '7 days'), (9, '9 days'), (12, '12 days'), )    # REQ-38
9
-THRESHOLD_SOON_CHOICES = ((1, '1 day'), (2, '2 days'), (3, '3 days'), (5, '5 days'), (7, '7 days'), (10, '10 days'), (14, '14 days'), (21, ' days'), )       # REQ-39
9
+THRESHOLD_SOON_CHOICES = ((1, '1 day'), (2, '2 days'), (3, '3 days'), (5, '5 days'), (7, '7 days'), (10, '10 days'), (14, '14 days'), (21, ' 21 days'), )       # REQ-39
10 10
 
11 11
 
12 12
 # PROJECTSTATE (REQ-??)

+ 0
- 1
urls.py 查看文件

@@ -6,7 +6,6 @@ from . import views
6 6
 
7 7
 urlpatterns = [
8 8
     path('', lambda request: redirect(reverse('patt-commonfilter', kwargs={'common_filter_id': SEARCH_MY_OPEN_TASKS}), permanent=False)),
9
-    path('profile', views.patt_profile, name='patt-profile'),
10 9
     #
11 10
     # views and urls
12 11
     #

+ 2
- 40
views.py 查看文件

@@ -7,14 +7,12 @@ from django.shortcuts import render, redirect
7 7
 from django.urls.base import reverse
8 8
 from django.utils import timezone
9 9
 from django.utils.translation import gettext as _
10
-from .forms import TaskForm, TaskFormLimited, ProjectForm, CommentForm, TaskCommentForm, SearchForm, EasySearchForm, PattUserProfileForm
10
+from .forms import TaskForm, TaskFormLimited, ProjectForm, CommentForm, TaskCommentForm, SearchForm, EasySearchForm
11 11
 from .help import help_pages
12 12
 from .models import Task, ModelList, Comment, TASKSTATE_CHOICES, PRIO_CHOICES, TASKS_IN_WORK
13
-from .models import Project, Search, get_pattuserprofile
13
+from .models import Project, Search
14 14
 import patt
15 15
 from .search import load_index, search, mk_search_pattern, get_project_ids_from_search_pattern, common_searches
16
-from users.forms import UserProfileForm
17
-from users.models import get_userprofile
18 16
 from themes import Context
19 17
 
20 18
 
@@ -144,42 +142,6 @@ def get_next(request):
144 142
         return request.POST.get('next', '/')
145 143
 
146 144
 
147
-def profile_post_actions(request, context):
148
-    if request.POST:
149
-        form = context.get('form_userprofile')
150
-        if form.is_valid():
151
-            form.save()
152
-        form = context.get('form_pattprofile')
153
-        if form.is_valid():
154
-            form.save()
155
-        return redirect(request.GET.get('next') or '/')
156
-
157
-
158
-def profile_pre_actions(request, context, form_to_be_used=UserProfileForm):
159
-    user_profile = get_userprofile(request.user)
160
-    patt_user_profile = get_pattuserprofile(request.user)
161
-    if request.POST:
162
-        userprofile_form = UserProfileForm(request.POST, instance=user_profile)
163
-        pattprofile_form = PattUserProfileForm(request.POST, instance=patt_user_profile)
164
-    else:
165
-        userprofile_form = UserProfileForm(instance=user_profile)
166
-        pattprofile_form = PattUserProfileForm(instance=patt_user_profile)
167
-    context['form_userprofile'] = userprofile_form
168
-    context['form_pattprofile'] = pattprofile_form
169
-
170
-
171
-@login_required
172
-def patt_profile(request):
173
-    context = Context(request)      # needs to be executed first because of time mesurement
174
-    profile_pre_actions(request, context)
175
-    response = profile_post_actions(request, context)
176
-    if response is not None:
177
-        return response
178
-    else:
179
-        context_adaption(context, request, title=_('Profile for %(username)s') % {'username': request.user.username})
180
-        return render(request, 'patt/profile.html', context=context)
181
-
182
-
183 145
 @login_required
184 146
 def patt_tasklist(request, user_filter_id=None, common_filter_id=None):
185 147
     context = Context(request)      # needs to be executed first because of time mesurement

Loading…
取消
儲存