diff --git a/rhodecode/controllers/files.py b/rhodecode/controllers/files.py --- a/rhodecode/controllers/files.py +++ b/rhodecode/controllers/files.py @@ -36,7 +36,7 @@ from pylons.decorators import jsonify 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 @@ class FilesController(BaseRepoController 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 @@ class FilesController(BaseRepoController @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 @@ class FilesController(BaseRepoController % (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 @@ class FilesController(BaseRepoController 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 @@ class FilesController(BaseRepoController 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 --git a/rhodecode/model/scm.py b/rhodecode/model/scm.py --- a/rhodecode/model/scm.py +++ b/rhodecode/model/scm.py @@ -360,7 +360,12 @@ class ScmModel(BaseModel): 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 --git a/rhodecode/public/css/codemirror.css b/rhodecode/public/css/codemirror.css --- a/rhodecode/public/css/codemirror.css +++ b/rhodecode/public/css/codemirror.css @@ -4,6 +4,7 @@ line-height: 1em; font-family: monospace; _position: relative; /* IE6 hack */ + margin:20px; } .CodeMirror-gutter { diff --git a/rhodecode/public/css/style.css b/rhodecode/public/css/style.css --- a/rhodecode/public/css/style.css +++ b/rhodecode/public/css/style.css @@ -928,6 +928,9 @@ font-weight:700; #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 @@ margin:0; 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 @@ border:1px solid #316293; 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 --git a/rhodecode/templates/files/files_add.html b/rhodecode/templates/files/files_add.html --- a/rhodecode/templates/files/files_add.html +++ b/rhodecode/templates/files/files_add.html @@ -36,7 +36,7 @@