Show More
@@ -36,7 +36,7 b' from pylons.decorators import jsonify' | |||
|
36 | 36 | |
|
37 | 37 | from vcs.conf import settings |
|
38 | 38 | from vcs.exceptions import RepositoryError, ChangesetDoesNotExistError, \ |
|
39 | EmptyRepositoryError, ImproperArchiveTypeError, VCSError | |
|
39 | EmptyRepositoryError, ImproperArchiveTypeError, VCSError, NodeAlreadyExistsError | |
|
40 | 40 | from vcs.nodes import FileNode, NodeKind |
|
41 | 41 | from vcs.utils import diffs as differ |
|
42 | 42 | |
@@ -73,9 +73,9 b' class FilesController(BaseRepoController' | |||
|
73 | 73 | return None |
|
74 | 74 | url_ = url('files_add_home', |
|
75 | 75 | repo_name=c.repo_name, |
|
76 | revision=0,f_path='') | |
|
77 | add_new = '<a href="%s">[%s]</a>' % (url_,_('add new')) | |
|
78 |
h.flash(h.literal(_('There are no files yet %s' % add_new)), |
|
|
76 | revision=0, f_path='') | |
|
77 | add_new = '<a href="%s">[%s]</a>' % (url_, _('add new')) | |
|
78 | h.flash(h.literal(_('There are no files yet %s' % add_new)), | |
|
79 | 79 | category='warning') |
|
80 | 80 | redirect(h.url('summary_home', repo_name=repo_name)) |
|
81 | 81 | |
@@ -295,7 +295,7 b' class FilesController(BaseRepoController' | |||
|
295 | 295 | @HasRepoPermissionAnyDecorator('repository.write', 'repository.admin') |
|
296 | 296 | def add(self, repo_name, revision, f_path): |
|
297 | 297 | r_post = request.POST |
|
298 |
c.cs = self.__get_cs_or_redirect(revision, repo_name, |
|
|
298 | c.cs = self.__get_cs_or_redirect(revision, repo_name, | |
|
299 | 299 | redirect_after=False) |
|
300 | 300 | if c.cs is None: |
|
301 | 301 | c.cs = EmptyChangeset(alias=c.rhodecode_repo.alias) |
@@ -310,6 +310,12 b' class FilesController(BaseRepoController' | |||
|
310 | 310 | % (f_path)) |
|
311 | 311 | location = r_post.get('location') |
|
312 | 312 | filename = r_post.get('filename') |
|
313 | file_obj = r_post.get('upload_file', None) | |
|
314 | ||
|
315 | if file_obj is not None and hasattr(file_obj, 'filename'): | |
|
316 | filename = file_obj.filename | |
|
317 | content = file_obj.file | |
|
318 | ||
|
313 | 319 | node_path = os.path.join(location, filename) |
|
314 | 320 | author = self.rhodecode_user.full_contact |
|
315 | 321 | |
@@ -320,7 +326,7 b' class FilesController(BaseRepoController' | |||
|
320 | 326 | if not filename: |
|
321 | 327 | h.flash(_('No filename'), category='warning') |
|
322 | 328 | return redirect(url('changeset_home', repo_name=c.repo_name, |
|
323 |
revision='tip')) |
|
|
329 | revision='tip')) | |
|
324 | 330 | |
|
325 | 331 | try: |
|
326 | 332 | self.scm_model.create_node(repo=c.rhodecode_repo, |
@@ -330,7 +336,8 b' class FilesController(BaseRepoController' | |||
|
330 | 336 | content=content, f_path=node_path) |
|
331 | 337 | h.flash(_('Successfully committed to %s' % node_path), |
|
332 | 338 | category='success') |
|
333 | ||
|
339 | except NodeAlreadyExistsError, e: | |
|
340 | h.flash(_(e), category='error') | |
|
334 | 341 | except Exception: |
|
335 | 342 | log.error(traceback.format_exc()) |
|
336 | 343 | h.flash(_('Error occurred during commit'), category='error') |
@@ -360,7 +360,12 b' class ScmModel(BaseModel):' | |||
|
360 | 360 | from vcs.backends.git import GitInMemoryChangeset as IMC |
|
361 | 361 | # decoding here will force that we have proper encoded values |
|
362 | 362 | # in any other case this will throw exceptions and deny commit |
|
363 | content = safe_str(content) | |
|
363 | ||
|
364 | if isinstance(content,(basestring,)): | |
|
365 | content = safe_str(content) | |
|
366 | elif isinstance(content,file): | |
|
367 | content = content.read() | |
|
368 | ||
|
364 | 369 | message = safe_str(message) |
|
365 | 370 | path = safe_str(f_path) |
|
366 | 371 | author = safe_str(author) |
@@ -4,6 +4,7 b'' | |||
|
4 | 4 | line-height: 1em; |
|
5 | 5 | font-family: monospace; |
|
6 | 6 | _position: relative; /* IE6 hack */ |
|
7 | margin:20px; | |
|
7 | 8 | } |
|
8 | 9 | |
|
9 | 10 | .CodeMirror-gutter { |
@@ -928,6 +928,9 b' font-weight:700;' | |||
|
928 | 928 | #content div.box div.form div.fields div.field div.input { |
|
929 | 929 | margin:0 0 0 200px; |
|
930 | 930 | } |
|
931 | #content div.box div.form div.fields div.field div.file { | |
|
932 | margin:0 0 0 200px; | |
|
933 | } | |
|
931 | 934 | #content div.box-left div.form div.fields div.field div.input,#content div.box-right div.form div.fields div.field div.input { |
|
932 | 935 | margin:0 0 0 0px; |
|
933 | 936 | } |
@@ -945,6 +948,17 b' margin:0;' | |||
|
945 | 948 | padding:7px 7px 6px; |
|
946 | 949 | } |
|
947 | 950 | |
|
951 | #content div.box div.form div.fields div.field div.file input { | |
|
952 | background: none repeat scroll 0 0 #FFFFFF; | |
|
953 | border-color: #B3B3B3 #EAEAEA #EAEAEA #B3B3B3; | |
|
954 | border-style: solid; | |
|
955 | border-width: 1px; | |
|
956 | color: #000000; | |
|
957 | font-family: Lucida Grande,Verdana,Lucida Sans Regular,Lucida Sans Unicode,Arial,sans-serif; | |
|
958 | font-size: 11px; | |
|
959 | margin: 0; | |
|
960 | padding: 7px 7px 6px; | |
|
961 | } | |
|
948 | 962 | |
|
949 | 963 | |
|
950 | 964 | #content div.box div.form div.fields div.field div.input input.small { |
@@ -2359,20 +2373,20 b' border:1px solid #316293;' | |||
|
2359 | 2373 | |
|
2360 | 2374 | |
|
2361 | 2375 | input.ui-button-small { |
|
2362 | background:#e5e3e3 url("../images/button.png") repeat-x; | |
|
2363 | border-top:1px solid #DDD; | |
|
2364 | border-left:1px solid #c6c6c6; | |
|
2365 | border-right:1px solid #DDD; | |
|
2366 | border-bottom:1px solid #c6c6c6; | |
|
2367 | color:#515151; | |
|
2368 | outline:none; | |
|
2369 | margin:0; | |
|
2370 | -webkit-border-radius: 4px 4px 4px 4px; | |
|
2371 | -khtml-border-radius: 4px 4px 4px 4px; | |
|
2372 | -moz-border-radius: 4px 4px 4px 4px; | |
|
2373 | border-radius: 4px 4px 4px 4px; | |
|
2374 | box-shadow: 0 1px 0 #ececec; | |
|
2375 | cursor: pointer; | |
|
2376 | background:#e5e3e3 url("../images/button.png") repeat-x !important; | |
|
2377 | border-top:1px solid #DDD !important; | |
|
2378 | border-left:1px solid #c6c6c6 !important; | |
|
2379 | border-right:1px solid #DDD !important; | |
|
2380 | border-bottom:1px solid #c6c6c6 !important; | |
|
2381 | color:#515151 !important; | |
|
2382 | outline:none !important; | |
|
2383 | margin:0 !important; | |
|
2384 | -webkit-border-radius: 4px 4px 4px 4px !important; | |
|
2385 | -khtml-border-radius: 4px 4px 4px 4px !important; | |
|
2386 | -moz-border-radius: 4px 4px 4px 4px !important; | |
|
2387 | border-radius: 4px 4px 4px 4px !important; | |
|
2388 | box-shadow: 0 1px 0 #ececec !important; | |
|
2389 | cursor: pointer !important; | |
|
2376 | 2390 | } |
|
2377 | 2391 | |
|
2378 | 2392 | input.ui-button-small:hover { |
@@ -36,7 +36,7 b'' | |||
|
36 | 36 | </div> |
|
37 | 37 | <div class="table"> |
|
38 | 38 | <div id="files_data"> |
|
39 | ${h.form(h.url.current(),method='post',id='eform')} | |
|
39 | ${h.form(h.url.current(),method='post',id='eform',enctype="multipart/form-data")} | |
|
40 | 40 | <h3>${_('Add new file')}</h3> |
|
41 | 41 | <div class="form"> |
|
42 | 42 | <div class="fields"> |
@@ -50,21 +50,33 b'' | |||
|
50 | 50 | </div> |
|
51 | 51 | </div> |
|
52 | 52 | |
|
53 | <div class="field"> | |
|
53 | <div id="filename_container" class="field file"> | |
|
54 | 54 | <div class="label"> |
|
55 | 55 | <label for="filename">${_('File Name')}:</label> |
|
56 | 56 | </div> |
|
57 | 57 | <div class="input"> |
|
58 | 58 | <input type="text" value="" size="30" name="filename" id="filename"> |
|
59 | <input type="button" class="ui-button-small" value="upload file" id="upload_file_enable"> | |
|
59 | 60 | </div> |
|
60 | </div> | |
|
61 | </div> | |
|
62 | <div id="upload_file_container" class="field" style="display:none"> | |
|
63 | <div class="label"> | |
|
64 | <label for="location">${_('Upload file')}</label> | |
|
65 | </div> | |
|
66 | <div class="file"> | |
|
67 | <input type="file" size="30" name="upload_file" id="upload_file"> | |
|
68 | <input type="button" class="ui-button-small" value="create file" id="file_enable"> | |
|
69 | </div> | |
|
70 | </div> | |
|
61 | 71 | </div> |
|
62 | 72 | </div> |
|
63 | 73 | <div id="body" class="codeblock"> |
|
64 |
< |
|
|
65 | <textarea id="editor" name="content" style="display:none"></textarea> | |
|
74 | <div id="editor_container"> | |
|
75 | <pre id="editor_pre"></pre> | |
|
76 | <textarea id="editor" name="content" style="display:none"></textarea> | |
|
77 | </div> | |
|
66 | 78 | <div style="padding: 10px;color:#666666">${_('commit message')}</div> |
|
67 | <textarea id="commit" name="message" style="height: 100px;width: 99%"></textarea> | |
|
79 | <textarea id="commit" name="message" style="height: 100px;width: 99%;margin-left:4px"></textarea> | |
|
68 | 80 | </div> |
|
69 | 81 | <div style="text-align: right;padding-top: 5px"> |
|
70 | 82 | <input id="reset" type="button" value="${_('Reset')}" class="ui-button-small" /> |
@@ -76,9 +88,22 b'' | |||
|
76 | 88 | mode: "null", |
|
77 | 89 | lineNumbers:true |
|
78 | 90 | }); |
|
79 | YUE.on('reset','click',function(){ | |
|
91 | YUE.on('reset','click',function(e){ | |
|
80 | 92 | window.location="${h.url('files_home',repo_name=c.repo_name,revision=c.cs.revision,f_path=c.f_path)}"; |
|
81 | }) | |
|
93 | }); | |
|
94 | ||
|
95 | YUE.on('file_enable','click',function(){ | |
|
96 | YUD.setStyle('editor_container','display',''); | |
|
97 | YUD.setStyle('upload_file_container','display','none'); | |
|
98 | YUD.setStyle('filename_container','display',''); | |
|
99 | }); | |
|
100 | ||
|
101 | YUE.on('upload_file_enable','click',function(){ | |
|
102 | YUD.setStyle('editor_container','display','none'); | |
|
103 | YUD.setStyle('upload_file_container','display',''); | |
|
104 | YUD.setStyle('filename_container','display','none'); | |
|
105 | }); | |
|
106 | ||
|
82 | 107 | </script> |
|
83 | 108 | </div> |
|
84 | 109 | </div> |
@@ -42,7 +42,7 b'' | |||
|
42 | 42 | <pre id="editor_pre"></pre> |
|
43 | 43 | <textarea id="editor" name="content" style="display:none">${c.file.content|n}</textarea> |
|
44 | 44 | <div style="padding: 10px;color:#666666">${_('commit message')}</div> |
|
45 |
<textarea id="commit" name="message" style="height: |
|
|
45 | <textarea id="commit" name="message" style="height: 60px;width: 99%;margin-left:4px"></textarea> | |
|
46 | 46 | </div> |
|
47 | 47 | <div style="text-align: right;padding-top: 5px"> |
|
48 | 48 | <input id="reset" type="button" value="${_('Reset')}" class="ui-button-small" /> |
General Comments 0
You need to be logged in to leave comments.
Login now