0001-pages-add-a-flag-root_for_search-40224.patch
combo/data/migrations/0046_search_on_root_page.py | ||
---|---|---|
1 |
# -*- coding: utf-8 -*- |
|
2 |
from __future__ import unicode_literals |
|
3 | ||
4 |
from django.db import migrations, models |
|
5 | ||
6 | ||
7 |
class Migration(migrations.Migration): |
|
8 | ||
9 |
dependencies = [ |
|
10 |
('data', '0045_link_list_limit'), |
|
11 |
] |
|
12 | ||
13 |
operations = [ |
|
14 |
migrations.AddField( |
|
15 |
model_name='page', |
|
16 |
name='root_for_search', |
|
17 |
field=models.BooleanField(default=False, verbose_name='Root for search'), |
|
18 |
), |
|
19 |
] |
combo/data/models.py | ||
---|---|---|
150 | 150 | |
151 | 151 |
picture = models.ImageField(_('Picture'), upload_to='page-pictures/', null=True) |
152 | 152 | |
153 |
root_for_search = models.BooleanField(_('Root for search'), default=False) |
|
154 | ||
153 | 155 |
# mark temporarily restored snapshots, it is required to save objects |
154 | 156 |
# (pages and cells) for real for viewing past snapshots as many cells are |
155 | 157 |
# asynchronously loaded and must refer to a real Page object. |
combo/manager/forms.py | ||
---|---|---|
131 | 131 |
return self.instance |
132 | 132 | |
133 | 133 | |
134 |
class PageEditRootForSearchForm(forms.ModelForm): |
|
135 |
class Meta: |
|
136 |
model = Page |
|
137 |
fields = ['root_for_search'] |
|
138 | ||
139 | ||
134 | 140 |
class CellVisibilityForm(forms.Form): |
135 | 141 |
visibility = forms.ChoiceField( |
136 | 142 |
label=_('Visibility'), |
combo/manager/templates/combo/page_view.html | ||
---|---|---|
66 | 66 |
(<a rel="popup" href="{% url 'combo-manager-page-edit-include-in-navigation' pk=object.id %}">{% trans 'change' %}</a>) |
67 | 67 |
</p> |
68 | 68 | |
69 |
<p> |
|
70 |
<label>{% trans 'Is root for search:' %}</label> |
|
71 |
{{ object.root_for_search|yesno }} |
|
72 |
(<a rel="popup" href="{% url 'combo-manager-page-edit-root-for-search' pk=object.id %}">{% trans 'change' %}</a>) |
|
73 |
</p> |
|
74 | ||
69 | 75 |
<p> |
70 | 76 |
<label>{% trans 'Redirection:' %}</label> |
71 | 77 |
{% if object.redirect_url %}{{ object.redirect_url }}{% else %}<i>{% trans 'none' %}</i>{% endif %} |
combo/manager/urls.py | ||
---|---|---|
14 | 14 |
# You should have received a copy of the GNU Affero General Public License |
15 | 15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | 16 | |
17 |
from django.conf.urls import url, include
|
|
17 |
from django.conf.urls import url |
|
18 | 18 |
from django.contrib.admin.views.decorators import staff_member_required |
19 | 19 |
from django.views.decorators.cache import never_cache |
20 | 20 | |
... | ... | |
40 | 40 |
name='combo-manager-page-edit-redirection'), |
41 | 41 |
url(r'^pages/(?P<pk>\d+)/include-in-navigation$', views.page_edit_include_in_navigation, |
42 | 42 |
name='combo-manager-page-edit-include-in-navigation'), |
43 |
url(r'^pages/(?P<pk>\d+)/root-for-search$', views.page_edit_root_for_search, |
|
44 |
name='combo-manager-page-edit-root-for-search'), |
|
43 | 45 |
url(r'^pages/(?P<pk>\d+)/slug$', views.page_edit_slug, |
44 | 46 |
name='combo-manager-page-edit-slug'), |
45 | 47 |
url(r'^pages/(?P<pk>\d+)/title$', views.page_edit_title, |
combo/manager/views.py | ||
---|---|---|
43 | 43 |
from .forms import (PageEditTitleForm, PageVisibilityForm, SiteImportForm, |
44 | 44 |
PageEditRedirectionForm, PageSelectTemplateForm, PageEditSlugForm, |
45 | 45 |
PageEditPictureForm, PageEditIncludeInNavigationForm, |
46 |
PageEditRootForSearchForm, |
|
46 | 47 |
PageEditDescriptionForm, CellVisibilityForm) |
47 | 48 | |
48 | 49 | |
... | ... | |
208 | 209 |
page_edit_include_in_navigation = PageEditIncludeInNavigationView.as_view() |
209 | 210 | |
210 | 211 | |
212 |
class PageEditRootForSearchView(PageEditView): |
|
213 |
form_class = PageEditRootForSearchForm |
|
214 |
comment = _('changed root for search') |
|
215 | ||
216 | ||
217 |
page_edit_root_for_search = PageEditRootForSearchView.as_view() |
|
218 | ||
219 | ||
211 | 220 |
class PageEditSlugView(PageEditView): |
212 | 221 |
form_class = PageEditSlugForm |
213 | 222 |
comment = _('changed slug') |
tests/test_manager.py | ||
---|---|---|
67 | 67 |
assert page.title == 'Home' |
68 | 68 |
assert page.template_name == 'standard' # first one was taken |
69 | 69 |
assert page.exclude_from_navigation is True |
70 |
assert page.root_for_search is False |
|
70 | 71 | |
71 | 72 | |
72 | 73 |
def test_add_second_page(app, admin_user): |
... | ... | |
153 | 154 |
resp = resp.form.submit() |
154 | 155 |
resp = resp.follow() |
155 | 156 |
assert Page.objects.all()[0].exclude_from_navigation is False |
157 |
# is root for search |
|
158 |
resp = resp.click(href='.*/root-for-search') |
|
159 |
resp.form['root_for_search'].checked = True |
|
160 |
resp = resp.form.submit() |
|
161 |
resp = resp.follow() |
|
162 |
assert Page.objects.all()[0].root_for_search is True |
|
163 |
# is not root for search |
|
164 |
resp = resp.click(href='.*/root-for-search') |
|
165 |
resp.form['root_for_search'].checked = False |
|
166 |
resp = resp.form.submit() |
|
167 |
resp = resp.follow() |
|
168 |
assert Page.objects.all()[0].root_for_search is False |
|
156 | 169 | |
157 | 170 | |
158 | 171 |
def test_edit_page_cell_invalid_placeholder(app, admin_user): |
159 |
- |