# HG changeset patch # User Marcin Kuzminski # Date 1316731968 -10800 # Node ID 269905fac50a6e1a674c16be7559f880119b8fb5 # Parent 1db451a445043f8c63fc0e6475443be5dab108bd added uploading of files from web interface directly into repo diff -r 1db451a44504 -r 269905fac50a rhodecode/controllers/files.py --- a/rhodecode/controllers/files.py Thu Sep 22 15:03:12 2011 +0300 +++ b/rhodecode/controllers/files.py Fri Sep 23 01:52:48 2011 +0300 @@ -36,7 +36,7 @@ from vcs.conf import settings from vcs.exceptions import RepositoryError, ChangesetDoesNotExistError, \ - EmptyRepositoryError, ImproperArchiveTypeError, VCSError + EmptyRepositoryError, ImproperArchiveTypeError, VCSError, NodeAlreadyExistsError from vcs.nodes import FileNode, NodeKind from vcs.utils import diffs as differ @@ -73,9 +73,9 @@ return None url_ = url('files_add_home', repo_name=c.repo_name, - revision=0,f_path='') - add_new = '[%s]' % (url_,_('add new')) - h.flash(h.literal(_('There are no files yet %s' % add_new)), + revision=0, f_path='') + add_new = '[%s]' % (url_, _('add new')) + h.flash(h.literal(_('There are no files yet %s' % add_new)), category='warning') redirect(h.url('summary_home', repo_name=repo_name)) @@ -295,7 +295,7 @@ @HasRepoPermissionAnyDecorator('repository.write', 'repository.admin') def add(self, repo_name, revision, f_path): r_post = request.POST - c.cs = self.__get_cs_or_redirect(revision, repo_name, + c.cs = self.__get_cs_or_redirect(revision, repo_name, redirect_after=False) if c.cs is None: c.cs = EmptyChangeset(alias=c.rhodecode_repo.alias) @@ -310,6 +310,12 @@ % (f_path)) location = r_post.get('location') filename = r_post.get('filename') + file_obj = r_post.get('upload_file', None) + + if file_obj is not None and hasattr(file_obj, 'filename'): + filename = file_obj.filename + content = file_obj.file + node_path = os.path.join(location, filename) author = self.rhodecode_user.full_contact @@ -320,7 +326,7 @@ if not filename: h.flash(_('No filename'), category='warning') return redirect(url('changeset_home', repo_name=c.repo_name, - revision='tip')) + revision='tip')) try: self.scm_model.create_node(repo=c.rhodecode_repo, @@ -330,7 +336,8 @@ content=content, f_path=node_path) h.flash(_('Successfully committed to %s' % node_path), category='success') - + except NodeAlreadyExistsError, e: + h.flash(_(e), category='error') except Exception: log.error(traceback.format_exc()) h.flash(_('Error occurred during commit'), category='error') diff -r 1db451a44504 -r 269905fac50a rhodecode/model/scm.py --- a/rhodecode/model/scm.py Thu Sep 22 15:03:12 2011 +0300 +++ b/rhodecode/model/scm.py Fri Sep 23 01:52:48 2011 +0300 @@ -360,7 +360,12 @@ from vcs.backends.git import GitInMemoryChangeset as IMC # decoding here will force that we have proper encoded values # in any other case this will throw exceptions and deny commit - content = safe_str(content) + + if isinstance(content,(basestring,)): + content = safe_str(content) + elif isinstance(content,file): + content = content.read() + message = safe_str(message) path = safe_str(f_path) author = safe_str(author) diff -r 1db451a44504 -r 269905fac50a rhodecode/public/css/codemirror.css --- a/rhodecode/public/css/codemirror.css Thu Sep 22 15:03:12 2011 +0300 +++ b/rhodecode/public/css/codemirror.css Fri Sep 23 01:52:48 2011 +0300 @@ -4,6 +4,7 @@ line-height: 1em; font-family: monospace; _position: relative; /* IE6 hack */ + margin:20px; } .CodeMirror-gutter { diff -r 1db451a44504 -r 269905fac50a rhodecode/public/css/style.css --- a/rhodecode/public/css/style.css Thu Sep 22 15:03:12 2011 +0300 +++ b/rhodecode/public/css/style.css Fri Sep 23 01:52:48 2011 +0300 @@ -928,6 +928,9 @@ #content div.box div.form div.fields div.field div.input { margin:0 0 0 200px; } +#content div.box div.form div.fields div.field div.file { +margin:0 0 0 200px; +} #content div.box-left div.form div.fields div.field div.input,#content div.box-right div.form div.fields div.field div.input { margin:0 0 0 0px; } @@ -945,6 +948,17 @@ padding:7px 7px 6px; } +#content div.box div.form div.fields div.field div.file input { + background: none repeat scroll 0 0 #FFFFFF; + border-color: #B3B3B3 #EAEAEA #EAEAEA #B3B3B3; + border-style: solid; + border-width: 1px; + color: #000000; + font-family: Lucida Grande,Verdana,Lucida Sans Regular,Lucida Sans Unicode,Arial,sans-serif; + font-size: 11px; + margin: 0; + padding: 7px 7px 6px; +} #content div.box div.form div.fields div.field div.input input.small { @@ -2359,20 +2373,20 @@ input.ui-button-small { -background:#e5e3e3 url("../images/button.png") repeat-x; -border-top:1px solid #DDD; -border-left:1px solid #c6c6c6; -border-right:1px solid #DDD; -border-bottom:1px solid #c6c6c6; -color:#515151; -outline:none; -margin:0; --webkit-border-radius: 4px 4px 4px 4px; --khtml-border-radius: 4px 4px 4px 4px; --moz-border-radius: 4px 4px 4px 4px; -border-radius: 4px 4px 4px 4px; -box-shadow: 0 1px 0 #ececec; -cursor: pointer; +background:#e5e3e3 url("../images/button.png") repeat-x !important; +border-top:1px solid #DDD !important; +border-left:1px solid #c6c6c6 !important; +border-right:1px solid #DDD !important; +border-bottom:1px solid #c6c6c6 !important; +color:#515151 !important; +outline:none !important; +margin:0 !important; +-webkit-border-radius: 4px 4px 4px 4px !important; +-khtml-border-radius: 4px 4px 4px 4px !important; +-moz-border-radius: 4px 4px 4px 4px !important; +border-radius: 4px 4px 4px 4px !important; +box-shadow: 0 1px 0 #ececec !important; +cursor: pointer !important; } input.ui-button-small:hover { diff -r 1db451a44504 -r 269905fac50a rhodecode/templates/files/files_add.html --- a/rhodecode/templates/files/files_add.html Thu Sep 22 15:03:12 2011 +0300 +++ b/rhodecode/templates/files/files_add.html Fri Sep 23 01:52:48 2011 +0300 @@ -36,7 +36,7 @@
- ${h.form(h.url.current(),method='post',id='eform')} + ${h.form(h.url.current(),method='post',id='eform',enctype="multipart/form-data")}

${_('Add new file')}

@@ -50,21 +50,33 @@
-
+
+
-
+
+
-

-				
+			    
+

+				    
+                
${_('commit message')}
- +
@@ -76,9 +88,22 @@ mode: "null", lineNumbers:true }); - YUE.on('reset','click',function(){ + YUE.on('reset','click',function(e){ window.location="${h.url('files_home',repo_name=c.repo_name,revision=c.cs.revision,f_path=c.f_path)}"; - }) + }); + + YUE.on('file_enable','click',function(){ + YUD.setStyle('editor_container','display',''); + YUD.setStyle('upload_file_container','display','none'); + YUD.setStyle('filename_container','display',''); + }); + + YUE.on('upload_file_enable','click',function(){ + YUD.setStyle('editor_container','display','none'); + YUD.setStyle('upload_file_container','display',''); + YUD.setStyle('filename_container','display','none'); + }); +
diff -r 1db451a44504 -r 269905fac50a rhodecode/templates/files/files_edit.html --- a/rhodecode/templates/files/files_edit.html Thu Sep 22 15:03:12 2011 +0300 +++ b/rhodecode/templates/files/files_edit.html Fri Sep 23 01:52:48 2011 +0300 @@ -42,7 +42,7 @@

 				
 				
${_('commit message')}
- +