[logaling-commit] logaling/logaling-server [prioritize-the-search] Create user glossary file to .logaling.d

Back to archive index

SUZUKI Miho null+****@clear*****
Tue Sep 25 20:59:42 JST 2012


SUZUKI Miho	2012-09-07 18:23:17 +0900 (Fri, 07 Sep 2012)

  New Revision: e71f17e3100684f7ecfd1dd5fe81cf25bff1ec68
  https://github.com/logaling/logaling-server/commit/e71f17e3100684f7ecfd1dd5fe81cf25bff1ec68

  Merged c5d082c: Merge pull request #13 from logaling/enable-creating-user-glossary

  Log:
    Create user glossary file to .logaling.d

  Modified files:
    app/controllers/user_glossaries_controller.rb
    app/models/user_glossary.rb

  Modified: app/controllers/user_glossaries_controller.rb (+9 -8)
===================================================================
--- app/controllers/user_glossaries_controller.rb    2012-09-07 18:22:23 +0900 (47fa180)
+++ app/controllers/user_glossaries_controller.rb    2012-09-07 18:23:17 +0900 (de08f6b)
@@ -22,14 +22,15 @@ class UserGlossariesController < ApplicationController
   # POST /user_glossaries.json
   def create
     #TODO: check user_id
-    #TODO: do loga new --personal
-    respond_to do |format|
-      if @user_glossary.save
-        format.html { render action: "show", notice: 'User glossary was successfully created.' }
-        format.json { render json: @user_glossary, status: :created, location: @user_glossary }
-      else
-        format.html { render action: "new" }
-        format.json { render json: @user_glossary.errors, status: :unprocessable_entity }
+    if @user_glossary.create
+      respond_to do |format|
+        if @user_glossary.save
+          format.html { render action: "show", notice: 'User glossary was successfully created.' }
+          format.json { render json: @user_glossary, status: :created, location: @user_glossary }
+        else
+          format.html { render action: "new" }
+          format.json { render json: @user_glossary.errors, status: :unprocessable_entity }
+        end
       end
     end
   end

  Modified: app/models/user_glossary.rb (+13 -0)
===================================================================
--- app/models/user_glossary.rb    2012-09-07 18:22:23 +0900 (6f47958)
+++ app/models/user_glossary.rb    2012-09-07 18:23:17 +0900 (34f8484)
@@ -2,4 +2,17 @@ class UserGlossary < ActiveRecord::Base
   attr_accessible :name, :source_language, :target_language
 
   belongs_to :user
+
+  #TODO: validation
+
+  def create
+    #TODO: check dupplication
+    begin
+      glossary_name = "%05d-%s"%[self.user_id, name]
+      personal_project = LogalingServer.repository.create_personal_project(glossary_name, source_language, target_language)
+    rescue Logaling::GlossaryAlreadyRegistered
+      false
+    end
+    true
+  end
 end
-------------- next part --------------
An HTML attachment was scrubbed...
Download 



More information about the logaling-commit mailing list
Back to archive index