Javier Novoa C. avatar Javier Novoa C. committed 6d3c6cc

Unicode support

Added cancel link in add document template
Added more info on log file <- better to override default log file in tmp dir to something more fixed
Unicode support for added documents
TODO: unicode support for comments
Minor bug fixes

Comments (0)

Files changed (3)

         self.added_fname = self.sanitized_title+".rst"
         # Verify that file doesn't exists already
-        if os.path.exists(self.fname_dir + self.added_fname):
+        if os.path.exists(self.fname_dir + os.sep + self.added_fname):
             raise forms.ValidationError("File already exists! Maybe you should change the Title?")
         return title


     <input type="submit" value="Enviar" />
+  <a href="{{ cancel }}">Cancelar</a>
 import smtplib, time, shutil
 from collections import defaultdict, namedtuple
 from StringIO import StringIO
+from codecs import open as copen
 # Settings for the ucomment application
 from conf import settings as conf
                 # Save documento at document_compile_area
-                    f = open(conf.local_repo_physical_dir + form.added_fname, "w")
+                    f = copen(form.fname_dir + os.sep + form.added_fname, "w", "utf-8")
                     log_file.info('Added file created: ' + form.added_fname)
-                except:
-                    log_file.error('Added file creation failed! (%s)' % form.added_fname)
+                except Exception as e:
+                    log_file.error('Added file creation failed! (%s): %s' % (form.added_fname, repr(e)))
                     request.user.message_set.create(message="Error al crear el archivo!")
                     return HttpResponseRedirect(django_reverse('ucomment-docman'))
                                  outdir = '/tmp', doctreedir = '/tmp',
                                  buildername = 'pickle')
-                except:
-                    log_file.error('Sphinx parameter loading failed!')
+                except Exception as e:
+                    log_file.error('Sphinx parameter loading failed!: %s' % repr(e))
                     request.user.message_set.create(message="Error al cargar parametros!")
                     return HttpResponseRedirect(django_reverse('ucomment-docman'))
-                master_doc = app.env.config.master_doc + ".rst"
+                master_doc = form.fname_dir + os.sep + app.env.config.master_doc + ".rst"
-                    f = open(conf.local_repo_physical_dir + master_doc, "r")
+                    f = copen(master_doc, "r", "utf-8")
                     lines = f.read()
-                    f.close
-                except:
-                    log_file.error('Reading contents file failed!')
+                    f.close()
+                except Exception as e:
+                    log_file.error('Reading contents file %s failed!: %s' % (master_doc, repr(e)))
                     request.user.message_set.create(message="Error al leer el contenido!")
                     return HttpResponseRedirect(django_reverse('ucomment-docman'))
-                lines = lines.split('\n')
-                idx = lines.index('.. toctree::') + 3
-                while idx < len(lines) and lines[idx] is not "":
+                lines = lines.split(u'\n')
+                idx = lines.index(u'.. toctree::') + 3
+                while idx < len(lines) and lines[idx] is not u"":
                     idx = idx + 1
-                lines.insert(idx, '   ' + form.sanitized_title)
+                lines.insert(idx, u'   ' + form.sanitized_title)
-                    f = open(conf.local_repo_physical_dir + master_doc, "w")
-                    f.write("\n".join(lines))
+                    f = copen(master_doc, "w", "utf-8")
+                    f.write(u"\n".join(lines))
                     log_file.info('Contents file updated')
-                except:
-                    log_file.error('Writing contents file failed!')
+                except Exception as e:
+                    log_file.error('Writing contents file %s failed!: %s' % (master_doc,repr(e)))
                     request.user.message_set.create(message="Error al escribir el contenido!")
                     return HttpResponseRedirect(django_reverse('ucomment-docman'))
             form = DocManForm()
-        return render_to_response('docmanpage_form.html', {'form': form}, context_instance=RequestContext(request))
+        return render_to_response('docmanpage_form.html',
+                                  {'form': form, 'cancel': django_reverse('ucomment-admin-signin')},
+                                  context_instance=RequestContext(request))
     elif request.method == 'GET':
         root = django_reverse('ucomment-root')
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.