Created
April 14, 2011 08:21
-
-
Save kracekumar/919123 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #controller | |
| class UploadMaterialController < ApplicationController | |
| def index | |
| end | |
| def upload | |
| @user = current_user | |
| @upload=UploadMaterial.new(params[:upload_material]) | |
| @upload.author=@user | |
| if @upload.name == nil | |
| flash[:notice]="File name empty" | |
| else | |
| name=@upload[:name].original_filename | |
| directory="public/uploads/materials" | |
| if UploadMaterial.find_by_name(name) == nil | |
| path=File.join(directory,name) | |
| @upload.name=name | |
| File.open(path,"wb"){ |f| f.write(params[:upload_material][:name].read) } | |
| @upload[:size]=(File.size("#{path}"))/1024.0 | |
| if @upload.save | |
| flash[:notice]="File saved" | |
| else | |
| flash[:notice]="#{@upload[:size]},#{params[:upload_material]}" | |
| end | |
| else | |
| flash[:notice]="#{params[:upload_material][:subject]} File name exists, please upload the file with other name" | |
| end | |
| end | |
| end | |
| end | |
| #view | |
| <div id="content-header"> | |
| <img src="/images/admission/admission_page_logo.jpg" /> | |
| <h1>Admission</h1> | |
| <h3>Step 1 - Student details</h3> | |
| <div id="app-back-button"> | |
| <%= link_to_function image_tag("/images/buttons/back.png",:border => 0), "history.back()" %> | |
| </div> | |
| </div> | |
| <div id="page-yield"> | |
| <% unless flash[:notice].nil? %> | |
| <p class="flash-msg"> <%= flash[:notice] %> </p> | |
| <% end %> | |
| <% form_for(@upload, :url => {:action=> 'upload'}, :html=> {:multipart=>true}) do |s| %> | |
| <%= error_messages_for 'upload_material', :header_message => nil %> | |
| <div id="admission1_form"> | |
| <div id="necessary-field-notification"> Fields marked with <span class="necessary-field">*</span> must be filled.</div> | |
| <span class="span-sub-heading">Personal Details</span> | |
| <hr class="sub-heading"></hr> | |
| <hr class="label-underline"></hr> | |
| <div class="label-field-pair"> | |
| <label for="student_grade">Description:<span class="necessary-field">*</span></label> | |
| <div class="text-input-bg"><%= s.text_field :description %></div> | |
| </div> | |
| <hr class="label-underline"></hr> | |
| <div id="admission1_form_vertical_block_left"> | |
| <div class="label-field-pair"> | |
| <% if @user.admin? %> | |
| <label for="student_grade">Course & Batch</label> | |
| <div class="text-input-bg"><%= select :subjects,:id, Subject.all.collect {|b| [b.name, b.id]} %></div> | |
| <% end %> | |
| </div> | |
| <hr class="label-underline"></hr> | |
| <div id="admission1_form_vertical_block_right"> | |
| <script> | |
| (function($){$.fn.filestyle=function(options){var settings={width:250};if(options){$.extend(settings,options);};return this.each(function(){var self=this;var wrapper=$("<div>").css({"width":settings.imagewidth+"px","height":settings.imageheight+"px","background":"url("+settings.image+") 0 0 no-repeat","background-position":"right","display":"inline","position":"absolute","overflow":"hidden"});var filename=$('<input class="file">').addClass($(self).attr("class")).css({"display":"inline","width":settings.width+"px"});$(self).before(filename);$(self).wrap(wrapper);$(self).css({"position":"relative","height":settings.imageheight+"px","width":settings.width+"px","display":"inline","cursor":"pointer","opacity":"0.0"});if($.browser.mozilla){if(/Win/.test(navigator.platform)){$(self).css("margin-left","-142px");}else{$(self).css("margin-left","-168px");};}else{$(self).css("margin-left",settings.imagewidth-settings.width+"px");};$(self).bind("change",function(){filename.val($(self).val());});});};})(jQuery); | |
| </script> | |
| <span class="span-sub-heading">Upload Material</span> | |
| <hr class="sub-heading"></hr> | |
| <div class="label-field-pair"> | |
| <label for="student_image_file">Upload ( 10MB max)</label> | |
| <div class="text-input-bg"><%= s.file_field :name %></div> | |
| </div> | |
| </div> | |
| <div class="extender"> | |
| </div> | |
| <%= submit_tag "", :value => "► Save & Proceed", :class => "submit_button" %> | |
| <% end %> | |
| </div> | |
| #html source | |
| <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" | |
| "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |
| <html> | |
| <head> | |
| <title> Happy School </title> | |
| <link href="/stylesheets/application.css?1302694012" media="screen" rel="stylesheet" type="text/css" /> | |
| <link href="/stylesheets/_styles/ui.all.css?1302694012" media="screen" rel="stylesheet" type="text/css" /> | |
| <link href="/stylesheets/upload_material/upload.css?1302723052" media="screen" rel="stylesheet" type="text/css" /> | |
| <link href="/stylesheets/modalbox.css?1302694012" media="screen" rel="stylesheet" type="text/css" /> | |
| <link href="/stylesheets/popup.css?1302694012" media="screen" rel="stylesheet" type="text/css" /> | |
| <script src="/javascripts/cache/javascripts/all.js?1302694012" type="text/javascript"></script> | |
| <script src="/javascripts/scripts/anylinkmenu.js?1302694012" type="text/javascript"></script> | |
| <script src="/javascripts/scripts/nicetitle.js?1302694012" type="text/javascript"></script> | |
| <script src="/javascripts/droplicious.js?1302694012" type="text/javascript"></script> | |
| <script src="/javascripts/fckeditor/fckeditor.js?1302694012" type="text/javascript"></script> | |
| <script src="/javascripts/builder.js?1302694012" type="text/javascript"></script> | |
| <script src="/javascripts/modalbox.js?1302694012" type="text/javascript"></script> | |
| <script src="/javascripts/calendar_date_select/calendar_date_select.js?1302694012" type="text/javascript"></script> | |
| <link href="/stylesheets/calendar_date_select/red.css?1302694012" media="screen" rel="stylesheet" type="text/css" /> | |
| <script type="text/javascript"> | |
| /*********************************************** | |
| * Dynamic Countdown script- © Dynamic Drive (http://www.dynamicdrive.com) | |
| * This notice MUST stay intact for legal use | |
| * Visit http://www.dynamicdrive.com/ for this script and 100s more. | |
| ***********************************************/ | |
| var anylinkmenu1={divclass:'anylinkmenu', inlinestyle:'', linktarget:''} //First menu variable. Make sure "anylinkmenu1" is a unique name! | |
| anylinkmenu1.items = [ | |
| ["Calendar", "/calendar"], | |
| ["Examination", "/exam"], | |
| ["News", "/news"], | |
| ["Event Creation", "/event"], | |
| ["Human Resource", "/employee/hr"], | |
| ["Finance", "/finance/index"], | |
| ["Users", "/user"], | |
| ] | |
| anylinkmenu.init("menuanchorclass"); | |
| </script> | |
| </head> | |
| <body> | |
| <div id="header_bg"> | |
| <div id="header"> | |
| <div id="main-menu"> | |
| <a href="/user/dashboard">Dashboard</a> | |
| <a href="/student">Students</a> | |
| <a href="/student_attendance">Attendance</a> | |
| <a href="/configuration">Settings</a> <!-- | |
| <a href="/news">News</a> --> | |
| <a href="/timetable">Timetable</a> | |
| <a href="#" class="menuanchorclass" rel="anylinkmenu1">More ▼</a> | |
| </div> | |
| <div id="header_link" > | |
| Logged in as: | |
| <a href="/user/profile/admin">Happy School</a> | | |
| <a href="/reminder">Messages</a>(0 | |
| ) | | |
| <a href="/user/logout">Log out</a> | |
| </div> | |
| </div> | |
| </div> | |
| <div id="content_wrapper" > | |
| <div id="side_bar"> | |
| <div id="sidebar_news_area"> | |
| </div> | |
| </div> | |
| <div id="content"> | |
| <div id="content-header"> | |
| <img src="/images/admission/admission_page_logo.jpg" /> | |
| <h1>Admission</h1> | |
| <h3>Step 1 - Student details</h3> | |
| <div id="app-back-button"> | |
| <a href="#" onclick="history.back(); return false;"><img alt="Back" border="0" src="/images/buttons/back.png?1302694012" /></a> | |
| </div> | |
| </div> | |
| <div id="page-yield"> | |
| <p class="flash-msg"> File name exists, please upload the file with other name </p> | |
| <form action="/upload_material/upload" class="new_upload_material" enctype="multipart/form-data" id="new_upload_material" method="post"><div style="margin:0;padding:0;display:inline"><input name="authenticity_token" type="hidden" value="cKHvmiaRGGBO6GnN6GlslujVk/LtMVDBmm8bAjatGvg=" /></div> | |
| <div id="admission1_form"> | |
| <div id="necessary-field-notification"> Fields marked with <span class="necessary-field">*</span> must be filled.</div> | |
| <span class="span-sub-heading">Personal Details</span> | |
| <hr class="sub-heading"></hr> | |
| <hr class="label-underline"></hr> | |
| <div class="label-field-pair"> | |
| <label for="student_grade">Description:<span class="necessary-field">*</span></label> | |
| <div class="text-input-bg"><input id="upload_material_description" name="upload_material[description]" size="30" type="text" value="true" /></div> | |
| </div> | |
| <hr class="label-underline"></hr> | |
| <div id="admission1_form_vertical_block_left"> | |
| <div class="label-field-pair"> | |
| <label for="student_grade">Course & Batch</label> | |
| <div class="text-input-bg"><select id="subjects_id" name="subjects[id]"><option value="1">ENGLISH</option> | |
| <option value="2">PHYSICS</option> | |
| <option value="3">CHEMISTRY</option> | |
| <option value="4">MATHS</option> | |
| <option value="5">BIOLOGY</option> | |
| <option value="6">PHYSICAL EDUCATION</option> | |
| <option value="7">TAMIL</option> | |
| <option value="8">FRENCH</option></select></div> | |
| </div> | |
| <hr class="label-underline"></hr> | |
| <div id="admission1_form_vertical_block_right"> | |
| <script> | |
| (function($){$.fn.filestyle=function(options){var settings={width:250};if(options){$.extend(settings,options);};return this.each(function(){var self=this;var wrapper=$("<div>").css({"width":settings.imagewidth+"px","height":settings.imageheight+"px","background":"url("+settings.image+") 0 0 no-repeat","background-position":"right","display":"inline","position":"absolute","overflow":"hidden"});var filename=$('<input class="file">').addClass($(self).attr("class")).css({"display":"inline","width":settings.width+"px"});$(self).before(filename);$(self).wrap(wrapper);$(self).css({"position":"relative","height":settings.imageheight+"px","width":settings.width+"px","display":"inline","cursor":"pointer","opacity":"0.0"});if($.browser.mozilla){if(/Win/.test(navigator.platform)){$(self).css("margin-left","-142px");}else{$(self).css("margin-left","-168px");};}else{$(self).css("margin-left",settings.imagewidth-settings.width+"px");};$(self).bind("change",function(){filename.val($(self).val());});});};})(jQuery); | |
| </script> | |
| <span class="span-sub-heading">Upload Material</span> | |
| <hr class="sub-heading"></hr> | |
| <div class="label-field-pair"> | |
| <label for="student_image_file">Upload ( 10MB max)</label> | |
| <div class="text-input-bg"><input id="upload_material_name" name="upload_material[name]" size="30" type="file" /></div> | |
| </div> | |
| </div> | |
| <div class="extender"> | |
| </div> | |
| <input class="submit_button" name="commit" type="submit" value="► Save & Proceed" /> | |
| </form> | |
| </div> | |
| </div> | |
| <div class="extender"></div> | |
| </div> | |
| <script type="text/javascript"> | |
| //<![CDATA[ | |
| new PeriodicalExecuter(function() {new Ajax.Updater('header_link', '/user/header_link', {asynchronous:true, evalScripts:true, parameters:'authenticity_token=' + encodeURIComponent('cKHvmiaRGGBO6GnN6GlslujVk/LtMVDBmm8bAjatGvg=')})}, 120) | |
| //]]> | |
| </script> | |
| <div id="footer"> | |
| <div id="footer_logo"> | |
| <div id="powered_by"> | |
| </div> | |
| </div> | |
| </div> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment