edit start

This commit is contained in:
Unknown
2018-02-01 15:59:59 +01:00
parent e9dc2dc48f
commit 9a5a0aa617
4 changed files with 51 additions and 43 deletions

68
.idea/workspace.xml generated
View File

@@ -2,13 +2,9 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="f314243c-cf5d-48a7-b986-5e05ee924c9f" name="Default" comment="">
<change beforePath="$PROJECT_DIR$/cookbook/forms.py" afterPath="$PROJECT_DIR$/cookbook/forms.py" />
<change beforePath="$PROJECT_DIR$/cookbook/tables.py" afterPath="$PROJECT_DIR$/cookbook/tables.py" />
<change beforePath="$PROJECT_DIR$/cookbook/templates/base.html" afterPath="$PROJECT_DIR$/cookbook/templates/base.html" />
<change beforePath="$PROJECT_DIR$/cookbook/templates/new_category.html" afterPath="$PROJECT_DIR$/cookbook/templates/new_category.html" />
<change beforePath="$PROJECT_DIR$/cookbook/templates/new_keyword.html" afterPath="$PROJECT_DIR$/cookbook/templates/new_keyword.html" />
<change beforePath="$PROJECT_DIR$/cookbook/urls.py" afterPath="$PROJECT_DIR$/cookbook/urls.py" />
<change beforePath="$PROJECT_DIR$/cookbook/views.py" afterPath="$PROJECT_DIR$/cookbook/views.py" />
<change beforePath="$PROJECT_DIR$/db.sqlite3" afterPath="$PROJECT_DIR$/db.sqlite3" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" value="true" />
@@ -53,8 +49,8 @@
<file leaf-file-name="views.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/cookbook/views.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="203">
<caret line="39" column="13" lean-forward="false" selection-start-line="39" selection-start-column="13" selection-end-line="39" selection-end-column="13" />
<state relative-caret-position="609">
<caret line="32" column="27" lean-forward="false" selection-start-line="32" selection-start-column="27" selection-end-line="32" selection-end-column="27" />
<folding>
<element signature="e#0#57#0" expanded="true" />
</folding>
@@ -62,13 +58,13 @@
</provider>
</entry>
</file>
<file leaf-file-name="tables.py" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/cookbook/tables.py">
<file leaf-file-name="forms.py" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/cookbook/forms.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="754">
<caret line="26" column="4" lean-forward="false" selection-start-line="26" selection-start-column="4" selection-end-line="26" selection-end-column="4" />
<state relative-caret-position="812">
<caret line="71" column="30" lean-forward="false" selection-start-line="71" selection-start-column="30" selection-end-line="71" selection-end-column="30" />
<folding>
<element signature="e#0#31#0" expanded="true" />
<element signature="e#0#42#0" expanded="true" />
</folding>
</state>
</provider>
@@ -114,13 +110,13 @@
<option value="$PROJECT_DIR$/requirements.txt" />
<option value="$PROJECT_DIR$/cookbook/templates/index.html" />
<option value="$PROJECT_DIR$/cookbook/models.py" />
<option value="$PROJECT_DIR$/cookbook/forms.py" />
<option value="$PROJECT_DIR$/cookbook/templates/base.html" />
<option value="$PROJECT_DIR$/cookbook/templates/new_category.html" />
<option value="$PROJECT_DIR$/cookbook/templates/new_keyword.html" />
<option value="$PROJECT_DIR$/cookbook/views.py" />
<option value="$PROJECT_DIR$/cookbook/urls.py" />
<option value="$PROJECT_DIR$/cookbook/tables.py" />
<option value="$PROJECT_DIR$/cookbook/views.py" />
<option value="$PROJECT_DIR$/cookbook/forms.py" />
</list>
</option>
</component>
@@ -210,7 +206,7 @@
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="DefaultHtmlFileTemplate" value="HTML File" />
<property name="com.intellij.database.dataSource.DataSourceTemplate" value="Sqlite (Xerial)" />
<property name="SearchEverywhereHistoryKey" value="new_&#9;FILE&#9;file://C:/Users/bene/Documents/Developement/Django/recipies/cookbook/templates/new_keyword.html&#10;tabl&#9;FILE&#9;file://C:/Users/bene/Documents/Developement/Django/recipies/cookbook/tables.py&#10;tablees&#9;null&#9;null&#10;base&#9;FILE&#9;file://C:/Users/bene/Documents/Developement/Django/recipies/cookbook/templates/base.html&#10;models&#9;FILE&#9;file://C:/Users/bene/Documents/Developement/Django/recipies/cookbook/models.py&#10;view&#9;FILE&#9;file://C:/Users/bene/Documents/Developement/Django/recipies/cookbook/views.py&#10;sett&#9;FILE&#9;file://C:/Users/bene/Documents/Developement/Django/recipies/Recipies/settings.py&#10;setting&#9;FILE&#9;file://F:/Developement/Django/Recipies/Recipies/settings.py&#10;model&#9;FILE&#9;file://F:/Developement/Django/Recipies/cookbook/models.py&#10;settings&#9;FILE&#9;file://F:/Developement/Django/Recipies/Recipies/settings.py&#10;forms&#9;FILE&#9;file://F:/Developement/Django/Recipies/cookbook/forms.py&#10;mode&#9;FILE&#9;file://F:/Developement/Django/Recipies/cookbook/models.py&#10;settin&#9;FILE&#9;file://F:/Developement/Django/Recipies/Recipies/settings.py" />
<property name="SearchEverywhereHistoryKey" value="forms&#9;FILE&#9;file://C:/Users/bene/Documents/Developement/Django/recipies/cookbook/forms.py&#10;new_&#9;FILE&#9;file://C:/Users/bene/Documents/Developement/Django/recipies/cookbook/templates/new_keyword.html&#10;tabl&#9;FILE&#9;file://C:/Users/bene/Documents/Developement/Django/recipies/cookbook/tables.py&#10;tablees&#9;null&#9;null&#10;base&#9;FILE&#9;file://C:/Users/bene/Documents/Developement/Django/recipies/cookbook/templates/base.html&#10;models&#9;FILE&#9;file://C:/Users/bene/Documents/Developement/Django/recipies/cookbook/models.py&#10;view&#9;FILE&#9;file://C:/Users/bene/Documents/Developement/Django/recipies/cookbook/views.py&#10;sett&#9;FILE&#9;file://C:/Users/bene/Documents/Developement/Django/recipies/Recipies/settings.py&#10;setting&#9;FILE&#9;file://F:/Developement/Django/Recipies/Recipies/settings.py&#10;model&#9;FILE&#9;file://F:/Developement/Django/Recipies/cookbook/models.py&#10;settings&#9;FILE&#9;file://F:/Developement/Django/Recipies/Recipies/settings.py&#10;mode&#9;FILE&#9;file://F:/Developement/Django/Recipies/cookbook/models.py&#10;settin&#9;FILE&#9;file://F:/Developement/Django/Recipies/Recipies/settings.py" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/venv" />
</component>
<component name="RecentsManager">
@@ -280,7 +276,7 @@
<window_info id="manage.py@Recipies" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32915568" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Python Console" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32915568" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.2585752" sideWeight="0.5" order="8" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.2585752" sideWeight="0.5" order="8" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32915568" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.2094811" sideWeight="0.5" order="1" side_tool="false" content_ui="combo" />
<window_info id="Docker" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
@@ -596,16 +592,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/cookbook/forms.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="734">
<caret line="69" column="18" lean-forward="true" selection-start-line="69" selection-start-column="18" selection-end-line="69" selection-end-column="18" />
<folding>
<element signature="e#0#42#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/cookbook/urls.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="319">
@@ -624,16 +610,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/cookbook/views.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="203">
<caret line="39" column="13" lean-forward="false" selection-start-line="39" selection-start-column="13" selection-end-line="39" selection-end-column="13" />
<folding>
<element signature="e#0#57#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/cookbook/tables.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="754">
@@ -644,5 +620,25 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/cookbook/views.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="609">
<caret line="32" column="27" lean-forward="false" selection-start-line="32" selection-start-column="27" selection-end-line="32" selection-end-column="27" />
<folding>
<element signature="e#0#57#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/cookbook/forms.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="812">
<caret line="71" column="30" lean-forward="false" selection-start-line="71" selection-start-column="30" selection-end-line="71" selection-end-column="30" />
<folding>
<element signature="e#0#42#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</component>
</project>

View File

@@ -14,7 +14,6 @@ class RecipeForm(forms.ModelForm):
'name': _('Name'),
'category': _('Category'),
'keywords': _('Keywords'),
}
help_texts = {
@@ -62,12 +61,13 @@ class KeywordForm(forms.ModelForm):
self.helper.add_input(Submit('save', _('Save'), css_class='btn-primary'))
class EditCategoryForm(forms.ModelForm):
class EditRecipeForm(forms.ModelForm):
class Meta:
model = Keyword
fields = ('name', 'description')
model = Recipe
fields = ('name', 'category', 'keywords')
labels = {
'name': _('Name'),
'description': _('Description'),
'category': _('Category'),
'keywords': _('Keywords'),
}

View File

@@ -24,7 +24,7 @@ class CategoryTable(tables.Table):
class KeywordTable(tables.Table):
id = tables.LinkColumn('edit_recipe', args=[A('id')])
class Meta:
model = Keyword
template_name = 'tables/table_template.html'

View File

@@ -21,7 +21,19 @@ def index(request):
@login_required
def edit_recipe(request, id):
return render(request, 'index.html')
if request.method == "POST":
form = RecipeForm(request.POST)
if form.is_valid():
recipe = form.save(commit=False)
recipe.created_by = request.user.id
recipe.save()
form.save_m2m()
return redirect('edit_recipe/' + id)
else:
recipe = Recipe.objects.get(id=id)
form = EditRecipeForm(instance=recipe)
return render(request, 'new_recipe.html', {'from': form})
@login_required