meblog / posts / postform.py

Diff from to

posts/postform.py

 #    You should have received a copy of the GNU General Public License
 #    along with MeBlog.  If not, see <http://www.gnu.org/licenses/>.
 
+
 import models
 from django import forms
 
+# this utils used to construct keyname from post or page title by removing unallowed char
+from utilities.utils import construct_keyname
+
+
 
 class PostForm(forms.Form):
     key = forms.CharField(required=False, widget=forms.HiddenInput())
 
     def save(self, post=None, commit=True):
         data = self.cleaned_data
-        if not post: post = models.Post(key_name=data['title'].replace(' ','-'))
+        if not post: post = models.Post(key_name=construct_keyname(data['title']))
         post.title = data['title']
-        post.body = data['body']
+        post.body = self.data['body']
         post.category = data['category']
         post.tags = data['tags'].split()
         if commit: post.put()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.