From 00c9fe0f913bc0387bb1564f8f28becb5c593ba1 Mon Sep 17 00:00:00 2001 From: "Breeze.Kay" Date: Sun, 29 May 2016 10:02:58 +0800 Subject: [PATCH 01/10] add dynamic tag support to work dynamic url and static url --- menu/migrations/0002_menuitem_is_dynamic.py | 20 ++++++++++++++++++++ menu/models.py | 9 +++++++++ 2 files changed, 29 insertions(+) create mode 100644 menu/migrations/0002_menuitem_is_dynamic.py diff --git a/menu/migrations/0002_menuitem_is_dynamic.py b/menu/migrations/0002_menuitem_is_dynamic.py new file mode 100644 index 0000000..9aa95e3 --- /dev/null +++ b/menu/migrations/0002_menuitem_is_dynamic.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.5 on 2016-05-29 09:47 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('menu', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='menuitem', + name='is_dynamic', + field=models.BooleanField(default=False, help_text='Should this is a dynamic URL?', verbose_name='Dynamic mode'), + ), + ] diff --git a/menu/models.py b/menu/models.py index ef1b7d5..0dd5f5d 100644 --- a/menu/models.py +++ b/menu/models.py @@ -85,6 +85,15 @@ class MenuItem(models.Model): help_text=_(u'Should this item only be shown to non-logged-in users?') ) + is_dynamic = models.BooleanField( + _(u'Dynamic mode'), + blank=True, + default=False, + help_text=_(u'Should this is a dynamic URL?') + ) + + + class Meta: verbose_name = _(u'menu item') verbose_name_plural = _(u'menu items') From f0d649d82a5a6489937cbd673535ba9ff1f65dd0 Mon Sep 17 00:00:00 2001 From: "Breeze.Kay" Date: Sun, 29 May 2016 10:03:26 +0800 Subject: [PATCH 02/10] upgrade translation file --- menu/locale/zh_Hans/LC_MESSAGES/django.mo | Bin 1478 -> 1588 bytes menu/locale/zh_Hans/LC_MESSAGES/django.po | 14 +++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/menu/locale/zh_Hans/LC_MESSAGES/django.mo b/menu/locale/zh_Hans/LC_MESSAGES/django.mo index 3150fffc48b4f22a8ae4b9dda4e282088b7244c4..b49ade1009489a606eb964d92528691edd82eb41 100644 GIT binary patch delta 572 zcmX}pKS%;m9Ki8AJu}l%FB=l2gBs#MC@RSsf{18nh`_ByvZ28mnwrk0qNU+zugxV1 zl!y|crG}P*mX>Hpsi~=<2<-d2JNm)9&-?Sc-+TA&He8QbFS>TD5D8j})}W_WfpZ7=F!AFX0VJ> zsESgkiHmrTQb=bv*)ZifjLrtg`J6+`4NCA0PA;#yvEnJ$-|O|`C>u!;3Ar6U(m9-r zgEaXC5^}J9n*17xn0=;>MizFr3Z>0;qqJSzu%FayY{w`VMQ<{{x;$6=RZTURGsbc= uQ{%Oa|3Hnl4lC{Q9*gbDX{&K$*R=_~eX{>vJ%78r`d_r;fkC^Y-TeV$`$wSw delta 479 zcmYk&ze)o^5XbSoP0mvjH68>k6f8v$!eK3r@)EKA5Ye%HyDtSw;k^2!J!~-tkBhKP8 zmT+M8hxNx;Wc}0p!kGFScksvD_J8|Mk$%IS^JSL}7uLAPIqELXV;^1rewaRn6?8m51)SRj|lM1>-}M;pQWdT9G<=fo#blC5Xi VUaj7_EVQCfiL=m*SHfBR_6tWPEz\n" "Language-Team: LANGUAGE \n" @@ -19,7 +19,7 @@ msgstr "" "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" "%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)\n" -#: menu/apps.py:8 menu/apps.py:9 +#: menu/apps.py:9 msgid "Menu" msgstr "菜单项" @@ -80,9 +80,17 @@ msgid "Should this item only be shown to non-logged-in users?" msgstr "设定当前菜单只在未登录时才显示" #: menu/models.py:89 +msgid "Dynamic mode" +msgstr "动态URL模式" + +#: menu/models.py:92 +msgid "Should this is a dynamic URL?" +msgstr "标记为动态URL" + +#: menu/models.py:98 msgid "menu item" msgstr "菜单" -#: menu/models.py:90 +#: menu/models.py:99 msgid "menu items" msgstr "菜单" From 93e7b8d9c49e440183d00e480b8a8b6cc21b7d55 Mon Sep 17 00:00:00 2001 From: "Breeze.Kay" Date: Sun, 29 May 2016 13:36:55 +0800 Subject: [PATCH 03/10] is_dynamic wrapper for template --- menu/templatetags/menubuilder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/menu/templatetags/menubuilder.py b/menu/templatetags/menubuilder.py index 6967ef8..e604a8a 100644 --- a/menu/templatetags/menubuilder.py +++ b/menu/templatetags/menubuilder.py @@ -87,7 +87,7 @@ def get_items(menu_name, current_path, user): show_anonymous = i.anonymous_only and user.is_anonymous() show_auth = i.login_required and user.is_authenticated() if (not (i.login_required or i.anonymous_only)) or (i.login_required and show_auth) or (i.anonymous_only and show_anonymous): - menuitems.append({'url': i.link_url, 'title': i.title, 'current': current,}) + menuitems.append({'url': i.link_url, 'title': i.title, 'current': current, 'is_dynamic': i.is_dynamic}) if cache_time >= 0 and not debug: cache.set(cache_key, menuitems, cache_time) From 41f33d261e17ffa6a47ee630584426fb9358da1a Mon Sep 17 00:00:00 2001 From: "Breeze.Kay" Date: Wed, 1 Jun 2016 09:08:11 +0800 Subject: [PATCH 04/10] update document for work reverse-url and static-url together --- README.rst | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/README.rst b/README.rst index de391e5..721ff9e 100644 --- a/README.rst +++ b/README.rst @@ -48,6 +48,29 @@ In your template, instead of the ``{% menu %}`` tag use ``{% submenu %}``. If a submenu for the current URI exists, it will be shown. The ``{{ submenu_items }}`` list contains your navigation items, ready to output like in the examples above. +Reverse URL: +------------ +begin 0.1.10, django-menu support make reverse-url and static-url together.::: + + {% if item.is_dynamic %} +
  • {{ item.title }}
  • + {% else %} +
  • {{ item.title }}
  • + {% endif %} + + +before 0.1.10, if you want make reverse-url and static-url together, +you have to do it like this.::: + + {% if item.title == 'reverse-url-01' %} +
  • {{ item.title }}
  • + {% elif item.title == 'reverse-url-02' %} +
  • {{ item.title }}
  • + {% else %} +
  • {{ item.title }}
  • + {% endif %} + + Caching: -------- To avoid hitting the database every time a user requests a page, the menu items are From f2a836fb9b123ec3426598864e5a79c1099e5e5f Mon Sep 17 00:00:00 2001 From: WANG WENPEI Date: Tue, 29 Nov 2016 18:54:44 +0800 Subject: [PATCH 05/10] rename field for readable reason --- README.rst | 12 +++++++----- menu/locale/zh_Hans/LC_MESSAGES/django.mo | Bin 1588 -> 1614 bytes menu/locale/zh_Hans/LC_MESSAGES/django.po | 15 +++++++-------- ...mic.py => 0002_menuitem_is_reverse_url.py} | 6 +++--- menu/models.py | 12 +++++++----- 5 files changed, 24 insertions(+), 21 deletions(-) rename menu/migrations/{0002_menuitem_is_dynamic.py => 0002_menuitem_is_reverse_url.py} (71%) diff --git a/README.rst b/README.rst index 721ff9e..7ce13a8 100644 --- a/README.rst +++ b/README.rst @@ -15,7 +15,7 @@ Installation & Configuration: 1. ``pip install django-menu`` -2. Add ``menu`` to your ``INSTALLED_APPS`` +2. Add ``django.contrib.sites`` and ``menu`` to your ``INSTALLED_APPS`` 3. ``./manage.py migrate menu`` (or ``./manage.py syncdb`` if you don't use South. You should use South.) @@ -50,21 +50,23 @@ list contains your navigation items, ready to output like in the examples above. Reverse URL: ------------ -begin 0.1.10, django-menu support make reverse-url and static-url together.::: +begin 0.1.11, django-menu support make reverse-url and static-url together.::: - {% if item.is_dynamic %} + {% if item.is_reverse_url %}
  • {{ item.title }}
  • {% else %}
  • {{ item.title }}
  • {% endif %} -before 0.1.10, if you want make reverse-url and static-url together, +before 0.1.11, if you want make reverse-url and static-url together, you have to do it like this.::: {% if item.title == 'reverse-url-01' %}
  • {{ item.title }}
  • - {% elif item.title == 'reverse-url-02' %} + {% elif item.title == 'another-reverse-url-02' %} +
  • {{ item.title }}
  • + {% elif .... %}
  • {{ item.title }}
  • {% else %}
  • {{ item.title }}
  • diff --git a/menu/locale/zh_Hans/LC_MESSAGES/django.mo b/menu/locale/zh_Hans/LC_MESSAGES/django.mo index b49ade1009489a606eb964d92528691edd82eb41..3c8f723b9f9640228212df87d00cea639f1ee3b5 100644 GIT binary patch delta 529 zcmYk&u}eZh90%~b_k3k(8iqk+^n!>G1x=8Qq(y?lDd<1w4HX$Egbnd@Y^Yw`5@Iz( zHWt{>P%aI%)EqRQ=oAf2HT3=26&)O(``!EUyL)%-efB!DwvRFP!5MQym&O>?eb5C% z$}wo5o`54T0+Vo2S%#Fqft0(0)9_yHf59HqTxYBodLZQnb!M{$4i8}?h>cftq2N30 zf}hY2HKe^Tpd5vii$KaHm1!78ol$PWDC!ENK97+4yuf)VjXBi_T{?}FX-EfTAnw<> zHN8ydGLW+Um~OGnhf@KpC{2Uj0e|y1y0M}oX?QRPFmd|N5Kny4w@@(i)|QnoSmyFl zR&XsA%&z9vsW5YvwetH_>}cclHBIN9csx3lGGnQkM512Qce(FiPdbOKi?im5LoNJ9 pBHR{@=Ki^?UdiK9^XO7KwRW}Cs+DEABLBtTZcl}642ccn;TtZ!R(AjZ delta 499 zcmXxgKTE?v7{~ETV$|ADYqd+Y7_fsB3h__HsvwAngOkt~P^@6V)PKByDuQ9`!9?IV zn#@y}#5B&~dZ3F^e}htYkMsB#{Qtoa^IsgmkkPFhF_f!XY@XmpoP}3Xr0^4a@f!zG zQl-&oU=pP+jZ!xoxQH?4E11SSX0V2m(?H2-;Tk@f%iW+DDH1dmID!5KNPm9Uax*eG zgkMXBQeIUX%}JzG%aD8EG=3X0@8b>22SZvI=9Rma5%r$6No%!QDU?fFc6qP3?HRfg zKiDbl+dKuk7%b&CH#}EQHFtGG3p?4&bk25i3)!jWp>d)`PV1f85hb1aW&7dG8!~5N Tor~j-#?|}nUHgC0tC(+pLUuyG diff --git a/menu/locale/zh_Hans/LC_MESSAGES/django.po b/menu/locale/zh_Hans/LC_MESSAGES/django.po index 6194e5d..730e266 100644 --- a/menu/locale/zh_Hans/LC_MESSAGES/django.po +++ b/menu/locale/zh_Hans/LC_MESSAGES/django.po @@ -3,12 +3,11 @@ # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. # -#, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-05-29 09:51+0800\n" +"POT-Creation-Date: 2016-11-29 09:33+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: Wang WenPei \n" "Language-Team: LANGUAGE \n" @@ -80,17 +79,17 @@ msgid "Should this item only be shown to non-logged-in users?" msgstr "设定当前菜单只在未登录时才显示" #: menu/models.py:89 -msgid "Dynamic mode" -msgstr "动态URL模式" +msgid "Is reverse URL" +msgstr "反向解析URL" #: menu/models.py:92 -msgid "Should this is a dynamic URL?" -msgstr "标记为动态URL" +msgid "Should Link URL need reverse?" +msgstr "链接地址是否需要做反向解析?" -#: menu/models.py:98 +#: menu/models.py:96 msgid "menu item" msgstr "菜单" -#: menu/models.py:99 +#: menu/models.py:97 msgid "menu items" msgstr "菜单" diff --git a/menu/migrations/0002_menuitem_is_dynamic.py b/menu/migrations/0002_menuitem_is_reverse_url.py similarity index 71% rename from menu/migrations/0002_menuitem_is_dynamic.py rename to menu/migrations/0002_menuitem_is_reverse_url.py index 9aa95e3..7acd011 100644 --- a/menu/migrations/0002_menuitem_is_dynamic.py +++ b/menu/migrations/0002_menuitem_is_reverse_url.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Generated by Django 1.9.5 on 2016-05-29 09:47 +# Generated by Django 1.9.7 on 2016-11-29 09:46 from __future__ import unicode_literals from django.db import migrations, models @@ -14,7 +14,7 @@ class Migration(migrations.Migration): operations = [ migrations.AddField( model_name='menuitem', - name='is_dynamic', - field=models.BooleanField(default=False, help_text='Should this is a dynamic URL?', verbose_name='Dynamic mode'), + name='is_reverse_url', + field=models.BooleanField(default=False, help_text='Should Link URL need reverse?', verbose_name='Is reverse URL'), ), ] diff --git a/menu/models.py b/menu/models.py index 0dd5f5d..b464e2e 100644 --- a/menu/models.py +++ b/menu/models.py @@ -85,18 +85,20 @@ class MenuItem(models.Model): help_text=_(u'Should this item only be shown to non-logged-in users?') ) - is_dynamic = models.BooleanField( - _(u'Dynamic mode'), + is_reverse_url = models.BooleanField( + _(u'Is reverse URL'), blank=True, default=False, - help_text=_(u'Should this is a dynamic URL?') + help_text=_(u'Should Link URL need reverse?') ) - - class Meta: verbose_name = _(u'menu item') verbose_name_plural = _(u'menu items') def __unicode__(self): return u"%s %s. %s" % (self.menu.slug, self.order, self.title) + + def __str__(self): + return self.__unicode__() + From a946561f0e65ed1ecd31fd07904e7d731a4e634b Mon Sep 17 00:00:00 2001 From: WANG WENPEI Date: Tue, 29 Nov 2016 18:56:22 +0800 Subject: [PATCH 06/10] document update --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 7ce13a8..e0b8500 100644 --- a/README.rst +++ b/README.rst @@ -15,7 +15,7 @@ Installation & Configuration: 1. ``pip install django-menu`` -2. Add ``django.contrib.sites`` and ``menu`` to your ``INSTALLED_APPS`` +2. Add ``menu`` to your ``INSTALLED_APPS`` 3. ``./manage.py migrate menu`` (or ``./manage.py syncdb`` if you don't use South. You should use South.) From 790cf5dfba063570eac0b3481fc82e2f44ff1c37 Mon Sep 17 00:00:00 2001 From: WANG WENPEI Date: Thu, 1 Dec 2016 11:53:48 +0800 Subject: [PATCH 07/10] rename is_dynamic to is_reverse_url --- menu/templatetags/menubuilder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/menu/templatetags/menubuilder.py b/menu/templatetags/menubuilder.py index e604a8a..44cc32d 100644 --- a/menu/templatetags/menubuilder.py +++ b/menu/templatetags/menubuilder.py @@ -87,7 +87,7 @@ def get_items(menu_name, current_path, user): show_anonymous = i.anonymous_only and user.is_anonymous() show_auth = i.login_required and user.is_authenticated() if (not (i.login_required or i.anonymous_only)) or (i.login_required and show_auth) or (i.anonymous_only and show_anonymous): - menuitems.append({'url': i.link_url, 'title': i.title, 'current': current, 'is_dynamic': i.is_dynamic}) + menuitems.append({'url': i.link_url, 'title': i.title, 'current': current, 'is_reverse_url': i.is_reverse_url}) if cache_time >= 0 and not debug: cache.set(cache_key, menuitems, cache_time) From 08daac5903c8f804cf1b7229884d4cd125f8eb6c Mon Sep 17 00:00:00 2001 From: WANG WENPEI Date: Fri, 9 Dec 2016 10:40:35 +0800 Subject: [PATCH 08/10] remove `__str__` method --- menu/models.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/menu/models.py b/menu/models.py index b464e2e..db8bf3e 100644 --- a/menu/models.py +++ b/menu/models.py @@ -32,9 +32,6 @@ class Meta: def __unicode__(self): return u"%s" % self.name - def __str__(self): - return self.__unicode__() - def save(self, *args, **kwargs): """ Re-order all items from 10 upwards, at intervals of 10. @@ -99,6 +96,5 @@ class Meta: def __unicode__(self): return u"%s %s. %s" % (self.menu.slug, self.order, self.title) - def __str__(self): - return self.__unicode__() + pass From 164865bcb3350b32c052c1d7d4b5707ef8979432 Mon Sep 17 00:00:00 2001 From: WANG WENPEI Date: Tue, 25 Apr 2017 14:11:45 +0800 Subject: [PATCH 09/10] improve .gitignore file --- .gitignore | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 32825cc..5a176c2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ *.pyc +*.pyo +*.egg-info dist -django_helpdesk.egg-info +build +.idea \ No newline at end of file From f3b75b9d4e2e60970543dcdd2bffe8baad2e2899 Mon Sep 17 00:00:00 2001 From: WANG WENPEI Date: Sat, 29 Apr 2017 10:44:42 +0800 Subject: [PATCH 10/10] =?UTF-8?q?=20=E8=A7=A3=E5=86=B3=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- menu/migrations/0002_booleandefaults.py | 7 +++++++ .../0002_menuitem_is_reverse_url.py | 20 ------------------- 2 files changed, 7 insertions(+), 20 deletions(-) delete mode 100644 menu/migrations/0002_menuitem_is_reverse_url.py diff --git a/menu/migrations/0002_booleandefaults.py b/menu/migrations/0002_booleandefaults.py index 58704b9..61a4473 100644 --- a/menu/migrations/0002_booleandefaults.py +++ b/menu/migrations/0002_booleandefaults.py @@ -22,4 +22,11 @@ class Migration(migrations.Migration): name='login_required', field=models.BooleanField(default=False, help_text='Should this item only be shown to authenticated users?', verbose_name='Login required'), ), + migrations.AddField( + model_name='menuitem', + name='is_reverse_url', + field=models.BooleanField(default=False, + help_text='Should Link URL need reverse?', + verbose_name='Is reverse URL'), + ), ] diff --git a/menu/migrations/0002_menuitem_is_reverse_url.py b/menu/migrations/0002_menuitem_is_reverse_url.py deleted file mode 100644 index 7acd011..0000000 --- a/menu/migrations/0002_menuitem_is_reverse_url.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.9.7 on 2016-11-29 09:46 -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('menu', '0001_initial'), - ] - - operations = [ - migrations.AddField( - model_name='menuitem', - name='is_reverse_url', - field=models.BooleanField(default=False, help_text='Should Link URL need reverse?', verbose_name='Is reverse URL'), - ), - ]