Compare commits

...

No commits in common. 'develop' and 'wechat_xz' have entirely different histories.

100 changed files with 1343 additions and 6193 deletions
Unified View
  1. +0
    -44
      .gitignore
  2. +0
    -268
      .metadata/.log
  3. BIN
      .metadata/.plugins/com.aptana.index.core/3084350319.index
  4. BIN
      .metadata/.plugins/com.aptana.index.core/3380472453.index
  5. BIN
      .metadata/.plugins/com.aptana.index.core/3406049957.index
  6. BIN
      .metadata/.plugins/com.aptana.index.core/645869811.index
  7. +0
    -5
      .metadata/.plugins/com.aptana.projects/dialog_settings.xml
  8. +0
    -11
      .metadata/.plugins/com.aptana.ruby.core/1184073882/4/argumenterror.rb
  9. +0
    -13
      .metadata/.plugins/com.aptana.ruby.core/1184073882/4/constants.rb
  10. +0
    -24
      .metadata/.plugins/com.aptana.ruby.core/1184073882/4/globals.rb
  11. +0
    -6
      .metadata/.plugins/com.aptana.ruby.ui/dialog_settings.xml
  12. BIN
      .metadata/.plugins/org.eclipse.core.resources/.projects/demo/.location
  13. +0
    -1
      .metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version
  14. BIN
      .metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index
  15. +0
    -1
      .metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version
  16. BIN
      .metadata/.plugins/org.eclipse.core.resources/.root/4.tree
  17. +0
    -3
      .metadata/.plugins/org.eclipse.core.resources/.safetable/com.aptana.core.io.15
  18. +0
    -4
      .metadata/.plugins/org.eclipse.core.resources/.safetable/com.aptana.syncing.core.15
  19. +0
    -3
      .metadata/.plugins/org.eclipse.core.resources/.safetable/com.aptana.webserver.core.12
  20. BIN
      .metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources
  21. +0
    -15
      .metadata/.plugins/org.eclipse.core.runtime/.settings/com.aptana.editor.common.prefs
  22. +0
    -2
      .metadata/.plugins/org.eclipse.core.runtime/.settings/com.aptana.explorer.prefs
  23. +0
    -2
      .metadata/.plugins/org.eclipse.core.runtime/.settings/com.aptana.js.core.prefs
  24. +0
    -2
      .metadata/.plugins/org.eclipse.core.runtime/.settings/com.aptana.portal.ui.prefs
  25. +0
    -3
      .metadata/.plugins/org.eclipse.core.runtime/.settings/com.aptana.rcp.prefs
  26. +0
    -2
      .metadata/.plugins/org.eclipse.core.runtime/.settings/com.aptana.ruby.core.prefs
  27. +0
    -8
      .metadata/.plugins/org.eclipse.core.runtime/.settings/com.aptana.theme.prefs
  28. +0
    -3
      .metadata/.plugins/org.eclipse.core.runtime/.settings/com.aptana.ui.prefs
  29. +0
    -4
      .metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs
  30. +0
    -7
      .metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.ui.prefs
  31. +0
    -2
      .metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.search.prefs
  32. +0
    -2
      .metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.browser.prefs
  33. +0
    -40
      .metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.editors.prefs
  34. +0
    -7
      .metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs
  35. +0
    -9
      .metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.texteditor.prefs
  36. +0
    -21
      .metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs
  37. +0
    -21
      .metadata/.plugins/org.eclipse.debug.core/.launches/Firefox - Internal Server.launch
  38. +0
    -21
      .metadata/.plugins/org.eclipse.debug.core/.launches/Internet Explorer - Internal Server.launch
  39. +0
    -25
      .metadata/.plugins/org.eclipse.debug.ui/launchConfigurationHistory.xml
  40. +0
    -3
      .metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/.workspace/2015/1/2/refactorings.history
  41. +0
    -2
      .metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/.workspace/2015/1/2/refactorings.index
  42. +0
    -7
      .metadata/.plugins/org.eclipse.ltk.ui.refactoring/dialog_settings.xml
  43. +0
    -26
      .metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml
  44. +0
    -12
      .metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml
  45. +0
    -206
      .metadata/.plugins/org.eclipse.ui.workbench/workbench.xml
  46. +0
    -4
      .metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml
  47. +0
    -1
      .metadata/version.ini
  48. +0
    -2
      .rspec
  49. +314
    -118
      Gemfile
  50. +1029
    -0
      Gemfile.lock
  51. +0
    -40
      Guardfile
  52. +0
    -5
      README.rdoc
  53. +0
    -7
      Rakefile
  54. +0
    -99
      ReadMe.txt
  55. +0
    -86
      app/api/mobile/api.rb
  56. +0
    -69
      app/api/mobile/apis/activities.rb
  57. +0
    -60
      app/api/mobile/apis/auth.rb
  58. +0
    -31
      app/api/mobile/apis/blog_comments.rb
  59. +0
    -133
      app/api/mobile/apis/comments.rb
  60. +0
    -934
      app/api/mobile/apis/courses.rb
  61. +0
    -157
      app/api/mobile/apis/homeworks.rb
  62. +0
    -44
      app/api/mobile/apis/issues.rb
  63. +0
    -41
      app/api/mobile/apis/journal_for_messages.rb
  64. +0
    -44
      app/api/mobile/apis/messages.rb
  65. +0
    -321
      app/api/mobile/apis/new_comment.rb
  66. +0
    -47
      app/api/mobile/apis/newss.rb
  67. +0
    -42
      app/api/mobile/apis/praise.rb
  68. +0
    -350
      app/api/mobile/apis/projects.rb
  69. +0
    -119
      app/api/mobile/apis/resources.rb
  70. +0
    -103
      app/api/mobile/apis/syllabuses.rb
  71. +0
    -29
      app/api/mobile/apis/upgrade.rb
  72. +0
    -320
      app/api/mobile/apis/users.rb
  73. +0
    -49
      app/api/mobile/apis/watches.rb
  74. +0
    -40
      app/api/mobile/apis/whomeworks.rb
  75. +0
    -195
      app/api/mobile/entities/activity.rb
  76. +0
    -36
      app/api/mobile/entities/anonymous_works_params.rb
  77. +0
    -58
      app/api/mobile/entities/attachment.rb
  78. +0
    -139
      app/api/mobile/entities/blog_comment.rb
  79. +0
    -30
      app/api/mobile/entities/comment.rb
  80. +0
    -114
      app/api/mobile/entities/course.rb
  81. +0
    -90
      app/api/mobile/entities/course_dynamic.rb
  82. +0
    -19
      app/api/mobile/entities/course_group.rb
  83. +0
    -43
      app/api/mobile/entities/exercise.rb
  84. +0
    -115
      app/api/mobile/entities/homework.rb
  85. +0
    -42
      app/api/mobile/entities/homework_attach.rb
  86. +0
    -29
      app/api/mobile/entities/homework_jours.rb
  87. +0
    -18
      app/api/mobile/entities/homeworkscore.rb
  88. +0
    -187
      app/api/mobile/entities/issue.rb
  89. +0
    -44
      app/api/mobile/entities/journal.rb
  90. +0
    -161
      app/api/mobile/entities/jours.rb
  91. +0
    -34
      app/api/mobile/entities/member.rb
  92. +0
    -154
      app/api/mobile/entities/message.rb
  93. +0
    -198
      app/api/mobile/entities/news.rb
  94. +0
    -43
      app/api/mobile/entities/project.rb
  95. +0
    -35
      app/api/mobile/entities/project_member.rb
  96. +0
    -45
      app/api/mobile/entities/student_work.rb
  97. +0
    -15
      app/api/mobile/entities/syllabus.rb
  98. +0
    -87
      app/api/mobile/entities/user.rb
  99. +0
    -119
      app/api/mobile/entities/whomework.rb
  100. +0
    -13
      app/api/mobile/exceptions/auth_exception.rb

+ 0
- 44
.gitignore View File

@@ -1,44 +0,0 @@
*.swp
/.project
/.idea
/.bundle
*.swp
/config/database.yml
/config/configuration.yml
/config/additional_environment.rb
/config/oneapm.yml
/config/environments/production.rb
/files/*
/log/*
/public/tmp/*
/tmp/*
/public/cache/*
/config/newrelic.yml
/public/images/avatars/*
/Gemfile
/Gemfile.lock
/db/schema.rb
/Gemfile.lock
/lib/plugins/acts_as_versioned/test/debug.log
.rbenv-gemsets
.DS_Store
public/api_doc/
/.metadata
vendor/cache
/files
/public/images/avatars
/public/files
/tags
/config/initializers/gitlab_config.rb
1234567
public/javascripts/wechat/node_modules/
.ruby-version
.access_token
tmux*.log
config/wechat.yml
config/oneapm.yml
/vendor
README.rdoc

+ 0
- 268
.metadata/.log View File

@@ -1,268 +0,0 @@
!SESSION 2014-03-11 16:33:06.446 -----------------------------------------------
eclipse.buildId=3.4.0.201304151603
java.version=1.6.0_24
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=zh_CN
Command-line arguments: -os win32 -ws win32 -arch x86
!ENTRY org.eclipse.equinox.p2.transport.ecf 2 0 2014-03-11 16:33:20.829
!MESSAGE Connection to http://download.aptana.com/studio3-rcp/plugin/update/p2.index failed on download.aptana.com. Retry attempt 0 started
!STACK 0
java.net.UnknownHostException: download.aptana.com
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at org.eclipse.ecf.provider.filetransfer.events.socket.SocketEventCreateUtil.createSocket(SocketEventCreateUtil.java:43)
at org.eclipse.ecf.internal.provider.filetransfer.httpclient.ECFHttpClientProtocolSocketFactory.createSocket(ECFHttpClientProtocolSocketFactory.java:81)
at org.eclipse.ecf.internal.provider.filetransfer.httpclient.ECFHttpClientProtocolSocketFactory.createSocket(ECFHttpClientProtocolSocketFactory.java:73)
at org.eclipse.ecf.internal.provider.filetransfer.httpclient.ECFHttpClientProtocolSocketFactory.createSocket(ECFHttpClientProtocolSocketFactory.java:65)
at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)
at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.open(MultiThreadedHttpConnectionManager.java:1361)
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346)
at org.eclipse.ecf.provider.filetransfer.httpclient.HttpClientRetrieveFileTransfer.performConnect(HttpClientRetrieveFileTransfer.java:1142)
at org.eclipse.ecf.provider.filetransfer.httpclient.HttpClientRetrieveFileTransfer.openStreams(HttpClientRetrieveFileTransfer.java:710)
at org.eclipse.ecf.provider.filetransfer.retrieve.AbstractRetrieveFileTransfer.sendRetrieveRequest(AbstractRetrieveFileTransfer.java:889)
at org.eclipse.ecf.provider.filetransfer.retrieve.AbstractRetrieveFileTransfer.sendRetrieveRequest(AbstractRetrieveFileTransfer.java:576)
at org.eclipse.ecf.provider.filetransfer.retrieve.MultiProtocolRetrieveAdapter.sendRetrieveRequest(MultiProtocolRetrieveAdapter.java:106)
at org.eclipse.equinox.internal.p2.transport.ecf.FileReader.sendRetrieveRequest(FileReader.java:349)
at org.eclipse.equinox.internal.p2.transport.ecf.FileReader.readInto(FileReader.java:295)
at org.eclipse.equinox.internal.p2.transport.ecf.RepositoryTransport.download(RepositoryTransport.java:87)
at org.eclipse.equinox.internal.p2.transport.ecf.RepositoryTransport.download(RepositoryTransport.java:137)
at org.eclipse.equinox.internal.p2.repository.helpers.AbstractRepositoryManager.loadIndexFile(AbstractRepositoryManager.java:721)
at org.eclipse.equinox.internal.p2.repository.helpers.AbstractRepositoryManager.loadRepository(AbstractRepositoryManager.java:640)
at org.eclipse.equinox.internal.p2.metadata.repository.MetadataRepositoryManager.loadRepository(MetadataRepositoryManager.java:96)
at org.eclipse.equinox.internal.p2.metadata.repository.MetadataRepositoryManager.loadRepository(MetadataRepositoryManager.java:92)
at org.eclipse.equinox.internal.p2.updatechecker.UpdateChecker.getAvailableRepositories(UpdateChecker.java:150)
at org.eclipse.equinox.internal.p2.updatechecker.UpdateChecker.checkForUpdates(UpdateChecker.java:128)
at org.eclipse.equinox.internal.p2.updatechecker.UpdateChecker$UpdateCheckThread.run(UpdateChecker.java:72)
!ENTRY org.eclipse.equinox.p2.transport.ecf 4 1006 2014-03-11 16:33:21.110
!MESSAGE Unknown Host: http://download.aptana.com/studio3-rcp/plugin/update/content.xml
!STACK 0
java.net.UnknownHostException: download.aptana.com
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at org.eclipse.ecf.provider.filetransfer.events.socket.SocketEventCreateUtil.createSocket(SocketEventCreateUtil.java:43)
at org.eclipse.ecf.internal.provider.filetransfer.httpclient.ECFHttpClientProtocolSocketFactory.createSocket(ECFHttpClientProtocolSocketFactory.java:81)
at org.eclipse.ecf.internal.provider.filetransfer.httpclient.ECFHttpClientProtocolSocketFactory.createSocket(ECFHttpClientProtocolSocketFactory.java:73)
at org.eclipse.ecf.internal.provider.filetransfer.httpclient.ECFHttpClientProtocolSocketFactory.createSocket(ECFHttpClientProtocolSocketFactory.java:65)
at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)
at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.open(MultiThreadedHttpConnectionManager.java:1361)
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346)
at org.eclipse.ecf.provider.filetransfer.httpclient.HttpClientFileSystemBrowser.runRequest(HttpClientFileSystemBrowser.java:227)
at org.eclipse.ecf.provider.filetransfer.browse.AbstractFileSystemBrowser$DirectoryJob.run(AbstractFileSystemBrowser.java:69)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
!SESSION 2014-03-11 16:46:11.935 -----------------------------------------------
eclipse.buildId=3.4.0.201304151603
java.version=1.6.0_24
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=zh_CN
Command-line arguments: -os win32 -ws win32 -arch x86
!ENTRY org.eclipse.equinox.p2.transport.ecf 2 0 2014-03-11 16:46:21.061
!MESSAGE Connection to http://download.aptana.com/studio3-rcp/plugin/update/p2.index failed on download.aptana.com. Retry attempt 0 started
!STACK 0
java.net.UnknownHostException: download.aptana.com
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at org.eclipse.ecf.provider.filetransfer.events.socket.SocketEventCreateUtil.createSocket(SocketEventCreateUtil.java:43)
at org.eclipse.ecf.internal.provider.filetransfer.httpclient.ECFHttpClientProtocolSocketFactory.createSocket(ECFHttpClientProtocolSocketFactory.java:81)
at org.eclipse.ecf.internal.provider.filetransfer.httpclient.ECFHttpClientProtocolSocketFactory.createSocket(ECFHttpClientProtocolSocketFactory.java:73)
at org.eclipse.ecf.internal.provider.filetransfer.httpclient.ECFHttpClientProtocolSocketFactory.createSocket(ECFHttpClientProtocolSocketFactory.java:65)
at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)
at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.open(MultiThreadedHttpConnectionManager.java:1361)
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346)
at org.eclipse.ecf.provider.filetransfer.httpclient.HttpClientRetrieveFileTransfer.performConnect(HttpClientRetrieveFileTransfer.java:1142)
at org.eclipse.ecf.provider.filetransfer.httpclient.HttpClientRetrieveFileTransfer.openStreams(HttpClientRetrieveFileTransfer.java:710)
at org.eclipse.ecf.provider.filetransfer.retrieve.AbstractRetrieveFileTransfer.sendRetrieveRequest(AbstractRetrieveFileTransfer.java:889)
at org.eclipse.ecf.provider.filetransfer.retrieve.AbstractRetrieveFileTransfer.sendRetrieveRequest(AbstractRetrieveFileTransfer.java:576)
at org.eclipse.ecf.provider.filetransfer.retrieve.MultiProtocolRetrieveAdapter.sendRetrieveRequest(MultiProtocolRetrieveAdapter.java:106)
at org.eclipse.equinox.internal.p2.transport.ecf.FileReader.sendRetrieveRequest(FileReader.java:349)
at org.eclipse.equinox.internal.p2.transport.ecf.FileReader.readInto(FileReader.java:295)
at org.eclipse.equinox.internal.p2.transport.ecf.RepositoryTransport.download(RepositoryTransport.java:87)
at org.eclipse.equinox.internal.p2.transport.ecf.RepositoryTransport.download(RepositoryTransport.java:137)
at org.eclipse.equinox.internal.p2.repository.helpers.AbstractRepositoryManager.loadIndexFile(AbstractRepositoryManager.java:721)
at org.eclipse.equinox.internal.p2.repository.helpers.AbstractRepositoryManager.loadRepository(AbstractRepositoryManager.java:640)
at org.eclipse.equinox.internal.p2.metadata.repository.MetadataRepositoryManager.loadRepository(MetadataRepositoryManager.java:96)
at org.eclipse.equinox.internal.p2.metadata.repository.MetadataRepositoryManager.loadRepository(MetadataRepositoryManager.java:92)
at org.eclipse.equinox.internal.p2.updatechecker.UpdateChecker.getAvailableRepositories(UpdateChecker.java:150)
at org.eclipse.equinox.internal.p2.updatechecker.UpdateChecker.checkForUpdates(UpdateChecker.java:128)
at org.eclipse.equinox.internal.p2.updatechecker.UpdateChecker$UpdateCheckThread.run(UpdateChecker.java:72)
!ENTRY org.eclipse.equinox.p2.transport.ecf 4 1006 2014-03-11 16:46:21.311
!MESSAGE Unknown Host: http://download.aptana.com/studio3-rcp/plugin/update/content.xml
!STACK 0
java.net.UnknownHostException: download.aptana.com
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at org.eclipse.ecf.provider.filetransfer.events.socket.SocketEventCreateUtil.createSocket(SocketEventCreateUtil.java:43)
at org.eclipse.ecf.internal.provider.filetransfer.httpclient.ECFHttpClientProtocolSocketFactory.createSocket(ECFHttpClientProtocolSocketFactory.java:81)
at org.eclipse.ecf.internal.provider.filetransfer.httpclient.ECFHttpClientProtocolSocketFactory.createSocket(ECFHttpClientProtocolSocketFactory.java:73)
at org.eclipse.ecf.internal.provider.filetransfer.httpclient.ECFHttpClientProtocolSocketFactory.createSocket(ECFHttpClientProtocolSocketFactory.java:65)
at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)
at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.open(MultiThreadedHttpConnectionManager.java:1361)
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346)
at org.eclipse.ecf.provider.filetransfer.httpclient.HttpClientFileSystemBrowser.runRequest(HttpClientFileSystemBrowser.java:227)
at org.eclipse.ecf.provider.filetransfer.browse.AbstractFileSystemBrowser$DirectoryJob.run(AbstractFileSystemBrowser.java:69)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
!ENTRY org.eclipse.core.resources 4 1 2014-03-11 16:49:31.442
!MESSAGE Problems occurred while refreshing local changes
!SUBENTRY 1 org.eclipse.core.resources 4 1 2014-03-11 16:49:31.442
!MESSAGE Problems occurred while refreshing local changes
!STACK 1
org.eclipse.core.internal.resources.ResourceException: Errors occurred while refreshing resources with the local file system.
at org.eclipse.core.internal.localstore.FileSystemResourceManager.refreshResource(FileSystemResourceManager.java:923)
at org.eclipse.core.internal.localstore.FileSystemResourceManager.refresh(FileSystemResourceManager.java:904)
at org.eclipse.core.internal.resources.Resource.refreshLocal(Resource.java:1663)
at org.eclipse.core.internal.refresh.RefreshJob.runInWorkspace(RefreshJob.java:167)
at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:38)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Contains: The project description file (.project) for 'trustie2' is missing. This file contains important information about the project. The project will not function properly until this file is restored.
!SUBENTRY 2 org.eclipse.core.resources 4 271 2014-03-11 16:49:31.442
!MESSAGE Errors occurred while refreshing resources with the local file system.
!SUBENTRY 3 org.eclipse.core.resources 4 567 2014-03-11 16:49:31.442
!MESSAGE The project description file (.project) for 'trustie2' is missing. This file contains important information about the project. The project will not function properly until this file is restored.
!ENTRY com.aptana.ruby.core 4 0 2014-03-11 17:05:47.412
!MESSAGE (eval):1: Use RbConfig instead of obsolete and deprecated Config.
(eval):1: warning: variable $= is no longer effective
(eval):1: warning: variable $KCODE is no longer effective
(eval):1: warning: variable $KCODE is no longer effective
D:/Users/nudt/AppData/Local/Aptana Studio 3/configuration/org.eclipse.osgi/bundles/93/1/.cp/ruby/core_stubber.rb:180:in `eval': Permission denied - E:\code\trustie\trustie2\.metadata\.plugins\com.aptana.ruby.core\1184073882\4 (Errno::EACCES)
from D:/Users/nudt/AppData/Local/Aptana Studio 3/configuration/org.eclipse.osgi/bundles/93/1/.cp/ruby/core_stubber.rb:180:in `eval'
from D:/Users/nudt/AppData/Local/Aptana Studio 3/configuration/org.eclipse.osgi/bundles/93/1/.cp/ruby/core_stubber.rb:180:in `block (3 levels) in <main>'
from D:/Users/nudt/AppData/Local/Aptana Studio 3/configuration/org.eclipse.osgi/bundles/93/1/.cp/ruby/core_stubber.rb:179:in `each'
from D:/Users/nudt/AppData/Local/Aptana Studio 3/configuration/org.eclipse.osgi/bundles/93/1/.cp/ruby/core_stubber.rb:179:in `block (2 levels) in <main>'
from D:/Users/nudt/AppData/Local/Aptana Studio 3/configuration/org.eclipse.osgi/bundles/93/1/.cp/ruby/core_stubber.rb:178:in `open'
from D:/Users/nudt/AppData/Local/Aptana Studio 3/configuration/org.eclipse.osgi/bundles/93/1/.cp/ruby/core_stubber.rb:178:in `block in <main>'
from D:/Users/nudt/AppData/Local/Aptana Studio 3/configuration/org.eclipse.osgi/bundles/93/1/.cp/ruby/core_stubber.rb:152:in `each'
from D:/Users/nudt/AppData/Local/Aptana Studio 3/configuration/org.eclipse.osgi/bundles/93/1/.cp/ruby/core_stubber.rb:152:in `<main>'
!ENTRY com.aptana.ruby.core 4 0 2014-03-11 17:05:50.704
!MESSAGE (Build 3.4.0.201304151603) [ERROR] Not supported yet.
!STACK 0
java.lang.UnsupportedOperationException: Not supported yet.
at org.jrubyparser.ast.LambdaNode.accept(LambdaNode.java:58)
at com.aptana.ruby.core.ast.AbstractVisitor.acceptNode(AbstractVisitor.java:37)
at com.aptana.ruby.core.ast.InOrderVisitor.visitHashNode(InOrderVisitor.java:414)
at org.jrubyparser.ast.HashNode.accept(HashNode.java:57)
at com.aptana.ruby.core.ast.AbstractVisitor.acceptNode(AbstractVisitor.java:37)
at com.aptana.ruby.core.ast.InOrderVisitor.visitCallNode(InOrderVisitor.java:193)
at com.aptana.ruby.core.ast.SourceElementVisitor.visitCallNode(SourceElementVisitor.java:230)
at org.jrubyparser.ast.CallNode.accept(CallNode.java:70)
at com.aptana.ruby.core.ast.AbstractVisitor.acceptNode(AbstractVisitor.java:53)
at com.aptana.ruby.core.ast.InOrderVisitor.visitLocalAsgnNode(InOrderVisitor.java:456)
at com.aptana.ruby.core.ast.SourceElementVisitor.visitLocalAsgnNode(SourceElementVisitor.java:839)
at org.jrubyparser.ast.LocalAsgnNode.accept(LocalAsgnNode.java:62)
at com.aptana.ruby.core.ast.AbstractVisitor.acceptNode(AbstractVisitor.java:53)
at com.aptana.ruby.core.ast.InOrderVisitor.visitIfNode(InOrderVisitor.java:438)
at org.jrubyparser.ast.IfNode.accept(IfNode.java:65)
at com.aptana.ruby.core.ast.AbstractVisitor.acceptNode(AbstractVisitor.java:53)
at com.aptana.ruby.core.ast.InOrderVisitor.visitNewlineNode(InOrderVisitor.java:525)
at org.jrubyparser.ast.NewlineNode.accept(NewlineNode.java:67)
at com.aptana.ruby.core.ast.AbstractVisitor.acceptNode(AbstractVisitor.java:37)
at com.aptana.ruby.core.ast.InOrderVisitor.visitDefnNode(InOrderVisitor.java:299)
at com.aptana.ruby.core.ast.SourceElementVisitor.visitDefnNode(SourceElementVisitor.java:346)
at org.jrubyparser.ast.DefnNode.accept(DefnNode.java:51)
at com.aptana.ruby.core.ast.AbstractVisitor.acceptNode(AbstractVisitor.java:53)
at com.aptana.ruby.core.ast.InOrderVisitor.visitNewlineNode(InOrderVisitor.java:525)
at org.jrubyparser.ast.NewlineNode.accept(NewlineNode.java:67)
at com.aptana.ruby.core.ast.AbstractVisitor.acceptNode(AbstractVisitor.java:37)
at com.aptana.ruby.core.ast.InOrderVisitor.visitClassNode(InOrderVisitor.java:213)
at com.aptana.ruby.core.ast.SourceElementVisitor.visitClassNode(SourceElementVisitor.java:260)
at org.jrubyparser.ast.ClassNode.accept(ClassNode.java:68)
at com.aptana.ruby.core.ast.AbstractVisitor.acceptNode(AbstractVisitor.java:53)
at com.aptana.ruby.core.ast.InOrderVisitor.visitNewlineNode(InOrderVisitor.java:525)
at org.jrubyparser.ast.NewlineNode.accept(NewlineNode.java:67)
at com.aptana.ruby.core.ast.AbstractVisitor.acceptNode(AbstractVisitor.java:37)
at com.aptana.ruby.core.ast.InOrderVisitor.visitModuleNode(InOrderVisitor.java:517)
at com.aptana.ruby.core.ast.SourceElementVisitor.visitModuleNode(SourceElementVisitor.java:824)
at org.jrubyparser.ast.ModuleNode.accept(ModuleNode.java:66)
at com.aptana.ruby.core.ast.AbstractVisitor.acceptNode(AbstractVisitor.java:53)
at com.aptana.ruby.core.ast.InOrderVisitor.visitNewlineNode(InOrderVisitor.java:525)
at org.jrubyparser.ast.NewlineNode.accept(NewlineNode.java:67)
at com.aptana.ruby.core.ast.AbstractVisitor.acceptNode(AbstractVisitor.java:37)
at com.aptana.ruby.core.ast.InOrderVisitor.visitRootNode(InOrderVisitor.java:668)
at com.aptana.ruby.core.ast.SourceElementVisitor.visitRootNode(SourceElementVisitor.java:848)
at org.jrubyparser.ast.RootNode.accept(RootNode.java:84)
at com.aptana.ruby.core.ast.AbstractVisitor.acceptNode(AbstractVisitor.java:53)
at com.aptana.ruby.internal.core.index.RubyFileIndexingParticipant.indexAST(RubyFileIndexingParticipant.java:73)
at com.aptana.ruby.internal.core.index.RubyFileIndexingParticipant.indexSource(RubyFileIndexingParticipant.java:61)
at com.aptana.ruby.internal.core.index.RubyFileIndexingParticipant.index(RubyFileIndexingParticipant.java:37)
at com.aptana.index.core.IndexRequestJob.indexFileStores(IndexRequestJob.java:205)
at com.aptana.index.core.IndexContainerJob.run(IndexContainerJob.java:114)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
!SESSION 2015-01-17 11:30:30.655 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.6.0_24
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=zh_CN
Command-line arguments: -os win32 -ws win32 -arch x86
!ENTRY org.eclipse.core.resources 4 567 2015-01-17 11:30:37.624
!MESSAGE Workspace restored, but some problems occurred.
!SUBENTRY 1 org.eclipse.core.resources 4 567 2015-01-17 11:30:37.624
!MESSAGE Could not read metadata for 'demo'.
!STACK 1
org.eclipse.core.internal.resources.ResourceException: The project description file (.project) for 'demo' is missing. This file contains important information about the project. The project will not function properly until this file is restored.
at org.eclipse.core.internal.localstore.FileSystemResourceManager.read(FileSystemResourceManager.java:851)
at org.eclipse.core.internal.resources.SaveManager.restoreMetaInfo(SaveManager.java:874)
at org.eclipse.core.internal.resources.SaveManager.restoreMetaInfo(SaveManager.java:854)
at org.eclipse.core.internal.resources.SaveManager.restore(SaveManager.java:703)
at org.eclipse.core.internal.resources.SaveManager.startup(SaveManager.java:1528)
at org.eclipse.core.internal.resources.Workspace.startup(Workspace.java:2503)
at org.eclipse.core.internal.resources.Workspace.open(Workspace.java:2251)
at org.eclipse.core.resources.ResourcesPlugin.start(ResourcesPlugin.java:439)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:299)
at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:440)
at org.eclipse.osgi.internal.loader.BundleLoader.setLazyTrigger(BundleLoader.java:268)
at org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:107)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:463)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:216)
at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:400)
at org.eclipse.osgi.internal.loader.SingleSourcePackage.loadClass(SingleSourcePackage.java:35)
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:473)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(Unknown Source)
at com.aptana.rcp.IDEApplication.start(IDEApplication.java:125)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
!SUBENTRY 2 org.eclipse.core.resources 4 567 2015-01-17 11:30:37.626
!MESSAGE The project description file (.project) for 'demo' is missing. This file contains important information about the project. The project will not function properly until this file is restored.
!ENTRY org.eclipse.core.jobs 2 2 2015-01-17 11:33:58.913
!MESSAGE Job found still running after platform shutdown. Jobs should be canceled by the plugin that scheduled them during shutdown: com.aptana.usage.internal.DefaultAnalyticsEventHandler$1

BIN
.metadata/.plugins/com.aptana.index.core/3084350319.index View File


BIN
.metadata/.plugins/com.aptana.index.core/3380472453.index View File


BIN
.metadata/.plugins/com.aptana.index.core/3406049957.index View File


BIN
.metadata/.plugins/com.aptana.index.core/645869811.index View File


+ 0
- 5
.metadata/.plugins/com.aptana.projects/dialog_settings.xml View File

@@ -1,5 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<section name="Workbench">
<section name="PromoteToProjectWizard">
</section>
</section>

+ 0
- 11
.metadata/.plugins/com.aptana.ruby.core/1184073882/4/argumenterror.rb View File

@@ -1,11 +0,0 @@
class ArgumentError < StandardError
protected
private
end

+ 0
- 13
.metadata/.plugins/com.aptana.ruby.core/1184073882/4/constants.rb View File

@@ -1,13 +0,0 @@
ARGV = []
TRUE = true
FALSE = false
STDOUT = IO.new
STDIN = IO.new
STDERR = IO.new
ENV = {}
NIL = nil
RUBY_PATCHLEVEL = 392
RUBY_COPYRIGHT = 'ruby - Copyright (C) 1993-2013 Yukihiro Matsumoto'
TOPLEVEL_BINDING = Binding.new
RUBY_VERSION = '1.9.3'
RUBY_PLATFORM = 'i386-mingw32'

+ 0
- 24
.metadata/.plugins/com.aptana.ruby.core/1184073882/4/globals.rb View File

@@ -1,24 +0,0 @@
$; = nil
$-F = nil
$@ = nil
$! = nil
$SAFE = 0
$~ = nil
$& = nil
$` = nil
$' = nil
$+ = nil
$= = false
$KCODE = nil
$-K = nil
$, = nil
$/ = "\n"
$-0 = "\n"
$\ = nil
$_ = nil
$stdin = IO.new
$stdout = IO.new
$stderr = IO.new
$> = IO.new
$< = ARGF
$. = 0

+ 0
- 6
.metadata/.plugins/com.aptana.ruby.ui/dialog_settings.xml View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<section name="Workbench">
<section name="BasicNewProjectResourceWizard">
<item value="E:\code" key="OUTSIDE_LOCATION"/>
</section>
</section>

BIN
.metadata/.plugins/org.eclipse.core.resources/.projects/demo/.location View File


+ 0
- 1
.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version View File

@@ -1 +0,0 @@


BIN
.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index View File


+ 0
- 1
.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version View File

@@ -1 +0,0 @@


BIN
.metadata/.plugins/org.eclipse.core.resources/.root/4.tree View File


+ 0
- 3
.metadata/.plugins/org.eclipse.core.resources/.safetable/com.aptana.core.io.15 View File

@@ -1,3 +0,0 @@
#safe table
#Mon Jan 05 10:27:54 CST 2015
connections=connections.15

+ 0
- 4
.metadata/.plugins/org.eclipse.core.resources/.safetable/com.aptana.syncing.core.15 View File

@@ -1,4 +0,0 @@
#safe table
#Mon Jan 05 10:27:54 CST 2015
defaultConnection=defaultConnection.15
sites=sites.15

+ 0
- 3
.metadata/.plugins/org.eclipse.core.resources/.safetable/com.aptana.webserver.core.12 View File

@@ -1,3 +0,0 @@
#safe table
#Mon Jan 05 10:27:28 CST 2015
webservers=webservers.12

BIN
.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources View File


+ 0
- 15
.metadata/.plugins/org.eclipse.core.runtime/.settings/com.aptana.editor.common.prefs View File

@@ -1,15 +0,0 @@
AbstractTextEditor.Color.Background=20,20,20
AbstractTextEditor.Color.Background.SystemDefault=false
AbstractTextEditor.Color.Foreground=248,248,248
AbstractTextEditor.Color.Foreground.SystemDefault=false
AbstractTextEditor.Color.SelectionForeground=248,248,248
AbstractTextEditor.Color.SelectionForeground.SystemDefault=false
CONFLICTING_COLOR=66,14,9
INCOMING_COLOR=235,235,235
OUTGOING_COLOR=235,235,235
RESOLVED_COLOR=37,59,34
additionIndicationColor=37,59,34
changeIndicationColor=37,59,34
currentLineColor=27,27,27
deletionIndicationColor=66,14,9
eclipse.preferences.version=1

+ 0
- 2
.metadata/.plugins/org.eclipse.core.runtime/.settings/com.aptana.explorer.prefs View File

@@ -1,2 +0,0 @@
activeProject=trustie
eclipse.preferences.version=1

+ 0
- 2
.metadata/.plugins/org.eclipse.core.runtime/.settings/com.aptana.js.core.prefs View File

@@ -1,2 +0,0 @@
JS_INDEX_VERSION=0.36
eclipse.preferences.version=1

+ 0
- 2
.metadata/.plugins/org.eclipse.core.runtime/.settings/com.aptana.portal.ui.prefs View File

@@ -1,2 +0,0 @@
eclipse.preferences.version=1
last_known_studio_version=3.4.2.1368863613

+ 0
- 3
.metadata/.plugins/org.eclipse.core.runtime/.settings/com.aptana.rcp.prefs View File

@@ -1,3 +0,0 @@
EDITOR_LINE_NUMBER_SET=true
WORKSPACE_ENCODING_SET=true
eclipse.preferences.version=1

+ 0
- 2
.metadata/.plugins/org.eclipse.core.runtime/.settings/com.aptana.ruby.core.prefs View File

@@ -1,2 +0,0 @@
eclipse.preferences.version=1
index_version=5

+ 0
- 8
.metadata/.plugins/org.eclipse.core.runtime/.settings/com.aptana.theme.prefs
File diff suppressed because it is too large
View File


+ 0
- 3
.metadata/.plugins/org.eclipse.core.runtime/.settings/com.aptana.ui.prefs View File

@@ -1,3 +0,0 @@
IDEHasLaunchedBefore=true
PerspectiveVersion=103
eclipse.preferences.version=1

+ 0
- 4
.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs View File

@@ -1,4 +0,0 @@
eclipse.preferences.version=1
encoding=UTF-8
refresh.enabled=true
version=1

+ 0
- 7
.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.ui.prefs View File

@@ -1,7 +0,0 @@
eclipse.preferences.version=1
org.eclipse.debug.ui.PREF_CHANGED_VALUE_BACKGROUND=74,65,13
org.eclipse.debug.ui.PREF_LAUNCH_PERSPECTIVES=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?>\r\n<launchPerspectives/>\r\n
org.eclipse.debug.ui.consoleBackground=20,20,20
org.eclipse.debug.ui.errorColor=255,0,0
org.eclipse.debug.ui.inColor=95,175,176
org.eclipse.debug.ui.outColor=248,248,248

+ 0
- 2
.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.search.prefs View File

@@ -1,2 +0,0 @@
eclipse.preferences.version=1
org.eclipse.search.potentialMatch.fgColor=94,101,105

+ 0
- 2
.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.browser.prefs View File

@@ -1,2 +0,0 @@
browsers=<?xml version\="1.0" encoding\="UTF-8"?>\r\n<web-browsers current\="0">\r\n<system/>\r\n<external location\="C\:\\Program Files\\Internet Explorer\\iexplore.exe" name\="Internet Explorer"/>\r\n</web-browsers>
eclipse.preferences.version=1

+ 0
- 40
.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.editors.prefs View File

@@ -1,40 +0,0 @@
AbstractTextEditor.Color.Background=20,20,20
AbstractTextEditor.Color.Background.SystemDefault=false
AbstractTextEditor.Color.Foreground=248,248,248
AbstractTextEditor.Color.Foreground.SystemDefault=false
AbstractTextEditor.Color.SelectionBackground=60,64,67
AbstractTextEditor.Color.SelectionBackground.SystemDefault=false
AbstractTextEditor.Color.SelectionForeground=248,248,248
AbstractTextEditor.Color.SelectionForeground.SystemDefault=false
CONFLICTING_COLOR=66,14,9
INCOMING_COLOR=235,235,235
OUTGOING_COLOR=235,235,235
OccurrenceIndicationColor=94,101,105
RESOLVED_COLOR=37,59,34
additionIndicationColor=37,59,34
changeIndicationColor=37,59,34
currentIPColor=14,34,49
currentLineColor=27,27,27
deletionIndicationColor=66,14,9
eclipse.preferences.version=1
htmlTagPairOccurrenceIndication=true
htmlTagPairOccurrenceIndicationColor=94,94,94
htmlTagPairOccurrenceIndicationHighlighting=false
htmlTagPairOccurrenceIndicationTextStyle=BOX
lineNumberRuler=true
occurrenceIndicationColor=60,64,67
pydevOccurrenceHighlighting=false
pydevOccurrenceIndication=true
pydevOccurrenceIndicationColor=94,94,94
pydevOccurrenceIndicationTextStyle=BOX
rubyBlockPairOccurrenceIndication=true
rubyBlockPairOccurrenceIndicationColor=94,94,94
rubyBlockPairOccurrenceIndicationHighlighting=false
rubyBlockPairOccurrenceIndicationTextStyle=BOX
searchResultIndicationColor=94,101,105
secondaryIPColor=14,34,49
writeOccurrenceIndicationColor=60,64,67
xmlTagPairOccurrenceIndication=true
xmlTagPairOccurrenceIndicationColor=94,94,94
xmlTagPairOccurrenceIndicationHighlighting=false
xmlTagPairOccurrenceIndicationTextStyle=BOX

+ 0
- 7
.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs View File

@@ -1,7 +0,0 @@
PROBLEMS_FILTERS_MIGRATE=true
SHOW_COOLBAR=true
SHOW_PERSPECTIVEBAR=true
eclipse.preferences.version=1
platformState=1420528131671
quickStart=false
tipsAndTricks=true

+ 0
- 9
.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.texteditor.prefs View File

@@ -1,9 +0,0 @@
AbstractTextEditor.Color.Background=20,20,20
AbstractTextEditor.Color.Background.SystemDefault=false
AbstractTextEditor.Color.Foreground=248,248,248
AbstractTextEditor.Color.Foreground.SystemDefault=false
AbstractTextEditor.Color.SelectionBackground=60,64,67
AbstractTextEditor.Color.SelectionForeground=248,248,248
AbstractTextEditor.Color.SelectionForeground.SystemDefault=false
currentLineColor=27,27,27
eclipse.preferences.version=1

+ 0
- 21
.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs View File

@@ -1,21 +0,0 @@
ACTIVE_HYPERLINK_COLOR=84,143,160
HYPERLINK_COLOR=84,143,160
com.vectrace.mercurialeclipse.ui.colorsandfonts.IgnoredBackgroundColor=20,20,20
com.vectrace.mercurialeclipse.ui.colorsandfonts.IgnoredForegroundColor=248,248,248
com.vectrace.mercurialeclipse.ui.colorsandfonts.addedBackgroundColor=37,59,34
com.vectrace.mercurialeclipse.ui.colorsandfonts.addedForegroundColor=248,248,248
com.vectrace.mercurialeclipse.ui.colorsandfonts.changedBackgroundColor=74,65,13
com.vectrace.mercurialeclipse.ui.colorsandfonts.changedForegroundColor=248,248,248
com.vectrace.mercurialeclipse.ui.colorsandfonts.conflictBackgroundColor=20,20,20
com.vectrace.mercurialeclipse.ui.colorsandfonts.conflictForegroundColor=248,248,248
com.vectrace.mercurialeclipse.ui.colorsandfonts.deletedBackgroundColor=66,14,9
com.vectrace.mercurialeclipse.ui.colorsandfonts.deletedForegroundColor=248,248,248
com.vectrace.mercurialeclipse.ui.colorsandfonts.removedBackgroundColor=66,14,9
com.vectrace.mercurialeclipse.ui.colorsandfonts.removedForegroundColor=248,248,248
com.vectrace.mercurialeclipse.ui.colorsandfonts.unknownBackgroundColor=20,20,20
com.vectrace.mercurialeclipse.ui.colorsandfonts.unknownForegroundColor=248,248,248
eclipse.preferences.version=1
hyperlinkColor=84,143,160
hyperlinkColor.SystemDefault=false
org.eclipse.egit.ui.UncommittedChangeBackgroundColor=37,59,34
org.eclipse.egit.ui.UncommittedChangeForegroundColor=248,248,248

+ 0
- 21
.metadata/.plugins/org.eclipse.debug.core/.launches/Firefox - Internal Server.launch View File

@@ -1,21 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="com.aptana.js.debug.core.webbrowserLaunchConfigurationType">
<booleanAttribute key="advancedRunEnabled" value="false"/>
<booleanAttribute key="appendProjectName" value="true"/>
<stringAttribute key="browserCmdLine" value=""/>
<stringAttribute key="browserExecutable" value="C:\Program Files (x86)\Mozilla Firefox\firefox.exe"/>
<stringAttribute key="browserNature" value="Firefox"/>
<stringAttribute key="externalBaseUrl" value=""/>
<stringAttribute key="httpGetData" value=""/>
<stringAttribute key="httpPostContentType" value=""/>
<stringAttribute key="httpPostData" value=""/>
<booleanAttribute key="overrideDebugPreferences" value="false"/>
<intAttribute key="serverType" value="1"/>
<intAttribute key="startActionType" value="1"/>
<stringAttribute key="startPagePath" value=""/>
<stringAttribute key="startPageUrl" value=""/>
<booleanAttribute key="suspendOnDebuggerKeywords" value="true"/>
<booleanAttribute key="suspendOnErrors" value="true"/>
<booleanAttribute key="suspendOnExceptions" value="false"/>
<booleanAttribute key="suspendOnFirstLine" value="false"/>
</launchConfiguration>

+ 0
- 21
.metadata/.plugins/org.eclipse.debug.core/.launches/Internet Explorer - Internal Server.launch View File

@@ -1,21 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="com.aptana.js.debug.core.webbrowserLaunchConfigurationType">
<booleanAttribute key="advancedRunEnabled" value="false"/>
<booleanAttribute key="appendProjectName" value="true"/>
<stringAttribute key="browserCmdLine" value=""/>
<stringAttribute key="browserExecutable" value="C:\Program Files (x86)\Internet Explorer\iexplore.exe"/>
<stringAttribute key="browserNature" value="Internet Explorer"/>
<stringAttribute key="externalBaseUrl" value=""/>
<stringAttribute key="httpGetData" value=""/>
<stringAttribute key="httpPostContentType" value=""/>
<stringAttribute key="httpPostData" value=""/>
<booleanAttribute key="overrideDebugPreferences" value="false"/>
<intAttribute key="serverType" value="1"/>
<intAttribute key="startActionType" value="1"/>
<stringAttribute key="startPagePath" value=""/>
<stringAttribute key="startPageUrl" value=""/>
<booleanAttribute key="suspendOnDebuggerKeywords" value="true"/>
<booleanAttribute key="suspendOnErrors" value="true"/>
<booleanAttribute key="suspendOnExceptions" value="false"/>
<booleanAttribute key="suspendOnFirstLine" value="false"/>
</launchConfiguration>

+ 0
- 25
.metadata/.plugins/org.eclipse.debug.ui/launchConfigurationHistory.xml View File

@@ -1,25 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchHistory>
<launchGroup id="org.eclipse.ui.externaltools.launchGroup">
<mruHistory/>
<favorites/>
</launchGroup>
<launchGroup id="org.eclipse.debug.ui.launchGroup.profile">
<mruHistory/>
<favorites/>
</launchGroup>
<launchGroup id="org.eclipse.debug.ui.launchGroup.debug">
<mruHistory>
<launch memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;launchConfiguration local=&quot;true&quot; path=&quot;Firefox - Internal Server&quot;/&gt;&#13;&#10;"/>
<launch memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;launchConfiguration local=&quot;true&quot; path=&quot;Internet Explorer - Internal Server&quot;/&gt;&#13;&#10;"/>
</mruHistory>
<favorites/>
</launchGroup>
<launchGroup id="org.eclipse.debug.ui.launchGroup.run">
<mruHistory>
<launch memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;launchConfiguration local=&quot;true&quot; path=&quot;Firefox - Internal Server&quot;/&gt;&#13;&#10;"/>
<launch memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;launchConfiguration local=&quot;true&quot; path=&quot;Internet Explorer - Internal Server&quot;/&gt;&#13;&#10;"/>
</mruHistory>
<favorites/>
</launchGroup>
</launchHistory>

+ 0
- 3
.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/.workspace/2015/1/2/refactorings.history View File

@@ -1,3 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<session version="1.0">&#x0A;<refactoring comment="Delete resource &apos;trustie2&apos;" deleteContents="false" description="Delete resource &apos;trustie2&apos;" element1="/trustie2" flags="7" id="org.eclipse.ltk.core.refactoring.delete.resources" resources="1" stamp="1420424676858"/>&#x0A;<refactoring comment="Delete resource &apos;trustie2&apos;" deleteContents="false" description="Delete resource &apos;trustie2&apos;" element1="/trustie2" flags="7" id="org.eclipse.ltk.core.refactoring.delete.resources" resources="1" stamp="1420424775104"/>
</session>

+ 0
- 2
.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/.workspace/2015/1/2/refactorings.index View File

@@ -1,2 +0,0 @@
1420424676858 Delete resource 'trustie2'
1420424775104 Delete resource 'trustie2'

+ 0
- 7
.metadata/.plugins/org.eclipse.ltk.ui.refactoring/dialog_settings.xml View File

@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<section name="Workbench">
<section name="RefactoringWizard.preview">
<item value="400" key="height"/>
<item value="600" key="width"/>
</section>
</section>

+ 0
- 26
.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml View File

@@ -1,26 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<section name="Workbench">
<list key="installedFeatures">
<item value="com.aptana.feature.rcp:3.4.2.201308081805-7o7nFDFFFcLz-2l0rkQ0UYz0u_Wm"/>
<item value="com.aptana.feature.studio:3.4.2.201308081736-7W7I57boG98RAi489ctbvKi7VXbq"/>
<item value="com.aptana.feature:3.4.2.1376005939-B87T88BWOnwWRYdZO1DC44EXtPxS"/>
<item value="com.aptana.php.feature:3.4.2.201308081728-7J7E-7IOYXVXXUJS"/>
<item value="com.aptana.pydev.feature:2.7.0.2013032300-7g9I-8Jez0cfdJcee"/>
<item value="org.eclipse.help:1.3.0.v20110530-0844-7i7uFFmFFl8nvqbDpEqTvx"/>
<item value="org.eclipse.platform:3.7.2.v20120207-1839-9gF7UHPDFxGjd-PqDr2jX_4yKaumkoHTz04_q-q"/>
<item value="org.eclipse.rcp:3.7.2.v20120120-1424-9DB5FmnFq5JCf1UA38R-kz0S0272"/>
<item value="org.radrails.rails:3.4.2.201308081726-7n-7Z7oKfjkqlemv"/>
</list>
<section name="ChooseWorkspaceDialogSettings">
<item value="316" key="DIALOG_Y_ORIGIN"/>
<item value="656" key="DIALOG_X_ORIGIN"/>
</section>
<section name="WORKBENCH_SETTINGS">
<list key="ENABLED_TRANSFERS">
</list>
</section>
<section name="ExternalProjectImportWizard">
<item value="false" key="WizardProjectsImportPage.STORE_ARCHIVE_SELECTED"/>
<item value="false" key="WizardProjectsImportPage.STORE_COPY_PROJECT_ID"/>
</section>
</section>

+ 0
- 12
.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml View File

@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<section name="Workbench">
<section name="NewWizardAction">
</section>
<section name="ImportExportAction">
<item value="org.eclipse.ui.wizards.import.ExternalProject" key="ImportExportPage.STORE_SELECTED_IMPORT_WIZARD_ID"/>
<list key="ImportExportPage.STORE_EXPANDED_IMPORT_CATEGORIES">
<item value="org.eclipse.ui.Basic"/>
<item value="com.aptana.git.ui.clone.category"/>
</list>
</section>
</section>

+ 0
- 206
.metadata/.plugins/org.eclipse.ui.workbench/workbench.xml View File

@@ -1,206 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<workbench progressCount="26" version="2.0">
<workbenchAdvisor/>
<window height="940" maximized="true" width="1200" x="13" y="31">
<fastViewData fastViewLocation="1024"/>
<perspectiveBar>
<itemSize x="160"/>
</perspectiveBar>
<coolbarLayout>
<coolItem id="group.file" itemType="typeGroupMarker"/>
<coolItem id="org.eclipse.ui.workbench.file" itemType="typeToolBarContribution" x="124" y="22"/>
<coolItem id="additions" itemType="typeGroupMarker"/>
<coolItem id="org.eclipse.debug.ui.launchActionSet" itemType="typeToolBarContribution" x="141" y="22"/>
<coolItem id="org.eclipse.search.searchActionSet" itemType="typeToolBarContribution" x="86" y="22"/>
<coolItem id="com.aptana.ui.globalActionSet" itemType="typeToolBarContribution" x="170" y="22"/>
<coolItem id="org.eclipse.ui.edit.text.actionSet.presentation" itemType="typeToolBarContribution" x="84" y="22"/>
<coolItem id="group.nav" itemType="typeGroupMarker"/>
<coolItem id="org.eclipse.ui.workbench.navigate" itemType="typeToolBarContribution" x="95" y="22"/>
<coolItem id="group.editor" itemType="typeGroupMarker"/>
<coolItem id="group.help" itemType="typeGroupMarker"/>
<coolItem id="org.eclipse.ui.workbench.help" itemType="typeToolBarContribution" x="-1" y="-1"/>
</coolbarLayout>
<page aggregateWorkingSetId="Aggregate for window 1394526806133" focus="true" label="Workspace - Web">
<editors>
<editorArea activeWorkbook="DefaultEditorWorkbook">
<info part="DefaultEditorWorkbook">
<folder appearance="1" expanded="2">
<presentation id="org.eclipse.ui.presentations.WorkbenchPresentationFactory"/>
</folder>
</info>
</editorArea>
</editors>
<views>
<view id="org.eclipse.ui.navigator.ProjectExplorer" partName="Project Explorer">
<viewState CommonNavigator.LINKING_ENABLED="0" org.eclipse.ui.navigator.resources.workingSets.showTopLevelWorkingSets="0"/>
</view>
<view id="com.aptana.terminal.views.terminal:demo" partName="demo">
<viewState>
<title>demo</title>
<workingDirectory>C:\Users\zh</workingDirectory>
</viewState>
</view>
<view id="com.aptana.snippets.ui.views.SnippetsView" partName="Snippets">
<viewState/>
</view>
<view id="com.aptana.terminal.views.terminal" partName="Terminal">
<viewState>
<title>Terminal</title>
<workingDirectory>C:\Users\nudt</workingDirectory>
</viewState>
</view>
<view id="com.aptana.samples.ui.SamplesView" partName="Samples">
<viewState/>
</view>
<view id="org.eclipse.ui.views.ProblemView" partName="Problems">
<viewState PRIMARY_SORT_FIELD="org.eclipse.ui.ide.severityAndDescriptionField" categoryGroup="org.eclipse.ui.ide.severity" markerContentGenerator="org.eclipse.ui.ide.problemsGenerator" partName="Problems">
<columnWidths org.eclipse.ui.ide.locationField="105" org.eclipse.ui.ide.markerType="105" org.eclipse.ui.ide.pathField="140" org.eclipse.ui.ide.resourceField="105" org.eclipse.ui.ide.severityAndDescriptionField="350"/>
<visible IMemento.internal.id="org.eclipse.ui.ide.severityAndDescriptionField"/>
<visible IMemento.internal.id="org.eclipse.ui.ide.resourceField"/>
<visible IMemento.internal.id="org.eclipse.ui.ide.pathField"/>
<visible IMemento.internal.id="org.eclipse.ui.ide.locationField"/>
<visible IMemento.internal.id="org.eclipse.ui.ide.markerType"/>
</viewState>
</view>
<view id="org.eclipse.ui.console.ConsoleView" partName="Console">
<viewState/>
</view>
<view id="com.aptana.explorer.view" partName="App Explorer">
<viewState CommonNavigator.LINKING_ENABLED="0" GitChangedFilesFilterEnabled="" activeProject="trustie">
<project name="trustie">
<selection>
<element path="/trustie"/>
</selection>
</project>
</viewState>
</view>
<view id="org.eclipse.ui.views.ContentOutline" partName="Outline">
<viewState/>
</view>
</views>
<perspectives activePart="org.eclipse.ui.navigator.ProjectExplorer" activePerspective="com.aptana.ui.WebPerspective">
<perspective editorAreaTrimState="2" editorAreaVisible="1" fixed="0" version="0.016">
<descriptor class="com.aptana.ui.internal.WebPerspectiveFactory" id="com.aptana.ui.WebPerspective" label="Web"/>
<alwaysOnActionSet id="com.aptana.browser.actionSet"/>
<alwaysOnActionSet id="com.aptana.ruby.debug.ui.RubyDebugActionSet"/>
<alwaysOnActionSet id="org.eclipse.ui.cheatsheets.actionSet"/>
<alwaysOnActionSet id="org.eclipse.search.searchActionSet"/>
<alwaysOnActionSet id="org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo"/>
<alwaysOnActionSet id="org.eclipse.ui.actionSet.keyBindings"/>
<alwaysOnActionSet id="org.eclipse.ui.actionSet.openFiles"/>
<alwaysOnActionSet id="com.aptana.editor.common.presentation"/>
<alwaysOnActionSet id="org.eclipse.debug.ui.launchActionSet"/>
<alwaysOnActionSet id="org.eclipse.debug.ui.breakpointActionSet"/>
<alwaysOnActionSet id="com.aptana.js.debug.ui.actionSet"/>
<alwaysOnActionSet id="org.eclipse.ui.NavigateActionSet"/>
<alwaysOnActionSet id="org.eclipse.ui.edit.text.actionSet.presentation"/>
<alwaysOnActionSet id="com.aptana.ui.globalActionSet"/>
<alwaysOnActionSet id="com.aptana.terminal.actionSet"/>
<show_view_action id="com.aptana.browser.views.webbrowser"/>
<show_view_action id="com.aptana.explorer.view"/>
<show_view_action id="org.eclipse.ui.navigator.ProjectExplorer"/>
<show_view_action id="com.aptana.ui.io.remoteview"/>
<show_view_action id="org.eclipse.ui.views.ContentOutline"/>
<show_view_action id="com.aptana.samples.ui.SamplesView"/>
<show_view_action id="com.aptana.snippets.ui.views.SnippetsView"/>
<show_view_action id="com.aptana.terminal.views.terminal"/>
<show_view_action id="org.eclipse.ui.console.ConsoleView"/>
<show_view_action id="org.eclipse.pde.runtime.LogView"/>
<show_view_action id="org.eclipse.ui.views.ProblemView"/>
<show_view_action id="org.eclipse.ui.views.TaskList"/>
<show_view_action id="com.aptana.webserver.ui.view"/>
<new_wizard_action id="com.aptana.editor.php.NewPHPProjectWizard"/>
<new_wizard_action id="com.aptana.ui.wizards.NewWebProject"/>
<new_wizard_action id="com.aptana.ruby.core.ui.rubyProjectWizard"/>
<new_wizard_action id="com.aptana.ui.wizards.new.file"/>
<new_wizard_action id="org.eclipse.ui.wizards.new.folder"/>
<new_wizard_action id="org.eclipse.ui.editors.wizards.UntitledTextFileWizard"/>
<new_wizard_action id="org.radrails.rails.ui.projectWizard"/>
<perspective_action id="org.eclipse.debug.ui.DebugPerspective"/>
<hide_toolbar_item_id id="org.eclipse.ui.edit.text.toggleShowSelectedElementOnly"/>
<view id="com.aptana.explorer.view"/>
<view id="org.eclipse.ui.navigator.ProjectExplorer"/>
<view id="org.eclipse.ui.console.ConsoleView"/>
<view id="com.aptana.terminal.views.terminal"/>
<view id="org.eclipse.ui.views.ProblemView"/>
<view id="com.aptana.terminal.views.terminal:demo"/>
<fastViewBars>
<fastViewBar fastViewLocation="16384" id="org.eclipse.ui.internal.ViewStack@d90254" orientation="256" selectedTabId="com.aptana.snippets.ui.views.SnippetsView" style="0">
<fastViews>
<view id="org.eclipse.ui.views.ContentOutline" ratio="0.3"/>
<view id="com.aptana.samples.ui.SamplesView" ratio="0.3"/>
<view id="com.aptana.snippets.ui.views.SnippetsView" ratio="0.3"/>
</fastViews>
</fastViewBar>
</fastViewBars>
<layout>
<mainWindow>
<info folder="true" part="left">
<folder activePageID="org.eclipse.ui.navigator.ProjectExplorer" appearance="2" expanded="2">
<page content="com.aptana.explorer.view" label="App Explorer"/>
<page content="org.eclipse.ui.navigator.ProjectExplorer" label="Project Explorer"/>
<page content="com.aptana.ui.io.remoteview" label="LabelNotFound"/>
<presentation id="org.eclipse.ui.presentations.WorkbenchPresentationFactory">
<part id="0"/>
<part id="1"/>
</presentation>
</folder>
</info>
<info folder="true" part="stickyFolderRight" ratio="0.7495741" ratioLeft="880" ratioRight="294" relationship="2" relative="left">
<folder appearance="2" expanded="2">
<page content="org.eclipse.help.ui.HelpView" label="LabelNotFound"/>
<page content="org.eclipse.ui.internal.introview" label="LabelNotFound"/>
<page content="org.eclipse.ui.cheatsheets.views.CheatSheetView" label="LabelNotFound"/>
</folder>
</info>
<info part="org.eclipse.ui.editorss" ratio="0.19931857" ratioLeft="234" ratioRight="940" relationship="2" relative="left"/>
<info folder="true" part="terminalArea" ratio="0.75" ratioLeft="627" ratioRight="209" relationship="4" relative="org.eclipse.ui.editorss">
<folder activePageID="com.aptana.terminal.views.terminal:demo" appearance="2" expanded="2">
<page content="org.eclipse.ui.console.ConsoleView" label="Console"/>
<page content="com.aptana.terminal.views.terminal" label="Terminal"/>
<page content="org.eclipse.ui.views.ProblemView" label="Problems"/>
<page content="com.aptana.terminal.views.terminal:demo" label="demo"/>
<page content="org.eclipse.pde.runtime.LogView" label="LabelNotFound"/>
<page content="org.eclipse.ui.views.TaskList" label="LabelNotFound"/>
<presentation id="org.eclipse.ui.presentations.WorkbenchPresentationFactory">
<part id="0"/>
<part id="1"/>
<part id="2"/>
<part id="3"/>
</presentation>
</folder>
</info>
<info folder="true" part="org.eclipse.ui.internal.ViewStack@d90254" ratio="0.75" ratioLeft="627" ratioRight="209" relationship="4" relative="left">
<folder appearance="2" expanded="0">
<page content="org.eclipse.ui.views.ContentOutline" label="LabelNotFound"/>
<page content="com.aptana.samples.ui.SamplesView" label="LabelNotFound"/>
<page content="com.aptana.snippets.ui.views.SnippetsView" label="LabelNotFound"/>
<presentation id="org.eclipse.ui.presentations.WorkbenchPresentationFactory"/>
</folder>
</info>
</mainWindow>
</layout>
</perspective>
</perspectives>
<workingSets/>
<navigationHistory/>
<input factoryID="org.eclipse.ui.internal.model.ResourceFactory" path="/" type="8"/>
</page>
<workbenchWindowAdvisor/>
<actionBarAdvisor/>
<trimLayout>
<trimArea IMemento.internal.id="16384">
<trimItem IMemento.internal.id="org.eclipse.ui.internal.ViewStack@d90254"/>
</trimArea>
<trimArea IMemento.internal.id="128">
<trimItem IMemento.internal.id="org.eclipse.ui.internal.WorkbenchWindow.topBar"/>
</trimArea>
<trimArea IMemento.internal.id="1024">
<trimItem IMemento.internal.id="org.eclise.ui.internal.FastViewBar"/>
<trimItem IMemento.internal.id="org.eclipse.jface.action.StatusLineManager"/>
<trimItem IMemento.internal.id="org.eclipse.ui.internal.progress.ProgressRegion"/>
</trimArea>
</trimLayout>
</window>
<mruList/>
</workbench>

+ 0
- 4
.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml View File

@@ -1,4 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<workingSetManager>
<workingSet aggregate="true" factoryID="org.eclipse.ui.internal.WorkingSetFactory" id="1394526806133_0" label="Window Working Set" name="Aggregate for window 1394526806133"/>
</workingSetManager>

+ 0
- 1
.metadata/version.ini View File

@@ -1 +0,0 @@
org.eclipse.core.runtime=1

+ 0
- 2
.rspec View File

@@ -1,2 +0,0 @@
--color
--require spec_helper

+ 314
- 118
Gemfile View File

@@ -1,118 +1,314 @@
source 'https://gems.ruby-china.com/'
unless RUBY_PLATFORM =~ /w32/
# unix-like only
gem 'iconv'
if RUBY_PLATFORM =~ /darwin/
# gem "rmagick", "= 2.15.4" ## osx must be this version
elsif RUBY_PLATFORM =~ /linux/
gem "rmagick", "~> 2.13.1" ## centos yum install ImageMagick-devel
gem 'simple_xlsx_reader'
end
gem 'certified'
gem 'net-ssh', '2.9.1'
gem 'jenkins_api_client'
gem 'nokogiri'
end
gem 'wechat',path: 'lib/wechat'
gem 'grack', path:'lib/grack'
gem 'gitlab', path: 'lib/gitlab-cli'
gem 'rest-client'
gem "mysql2", "= 0.3.18"
gem 'redis-rails'
gem 'rubyzip'
gem 'delayed_job_active_record'#, :group => :production
gem 'daemons'
gem 'grape', '~> 0.9.0'
gem 'grape-entity', '= 0.4.5'
gem 'rack-cors', :require => 'rack/cors'
gem 'seems_rateable', '~> 1.0.13'
gem 'rails', '~> 3.2'
gem "jquery-rails", "~> 2.0.2"
gem "i18n", "~> 0.6.0"
gem 'coderay', '~> 1.1.0'
gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby]
gem "builder", "3.0.0"
gem 'acts-as-taggable-on', '2.4.1'
gem 'spreadsheet'
gem 'ruby-ole'
gem 'rails_kindeditor',path:'lib/rails_kindeditor'
gem 'binding_of_caller'
gem 'chinese_pinyin'
# gem 'sunspot_rails', '~> 1.3.3'
# gem 'sunspot_solr'
# gem 'sunspot'
# gem 'progress_bar'
gem 'ansi'
gem 'kaminari'
gem 'elasticsearch-model'
gem 'elasticsearch-rails'
#rails 3.2.22.2 bug
# gem "test-unit", "~>3.0"
### profile
# gem 'oneapm_rpm'
# gem 'therubyracer'
group :development do
gem 'grape-swagger'
gem 'better_errors', '~> 1.1.0'
# gem "query_reviewer"
gem 'rack-mini-profiler', '~> 0.9.3'
if RUBY_PLATFORM =~ /w32/
gem 'win32console'
end
if RUBY_PLATFORM =~ /darwin/
gem 'puma'
end
end
group :development, :test do
if RUBY_VERSION >= '2.0.0'
gem 'pry-byebug'
gem "test-unit", "~>3.0"
end
# gem 'rspec-rails', '~> 3.0'
gem 'factory_girl_rails'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
end
# Optional gem for LDAP authentication
group :ldap do
gem "net-ldap", "~> 0.3.1"
end
# Optional gem for OpenID authentication
group :openid do
gem "ruby-openid", "~> 2.1.4", :require => "openid"
gem "rack-openid"
end
database_file = File.join(File.dirname(__FILE__), "config/database.yml")
if File.exist?(database_file)
else
warn("Please configure your config/database.yml first")
end
# Load plugins' Gemfiles
Dir.glob File.expand_path("../plugins/*/Gemfile", __FILE__) do |file|
puts "Loading #{file} ..." if $DEBUG # `ruby -d` or `bundle -v`
instance_eval File.read(file)
end
source "https://ruby.taobao.org"

#<<<<<<< HEAD
gem 'trustie', path: '../gems/trustie'
#gem 'rails', '4.1.11'
#=======
gem 'rails', '4.2.4'
gem 'rails-deprecated_sanitizer', '~> 1.0.3'

# Responders respond_to and respond_with
gem 'responders', '~> 2.0'
#>>>>>>> abf54f230ef7ff80c0ca1baa6a3c4c3d0cbb7869

# Specify a sprockets version due to security issue
# See https://groups.google.com/forum/#!topic/rubyonrails-security/doAVp0YaTqY
gem 'sprockets', '~> 2.12.3'

# Default values for AR models
gem "default_value_for", "~> 3.0.0"

# Supported DBs
gem "mysql2", '~> 0.3.16', group: :mysql
gem "pg", '~> 0.18.2', group: :postgres

# Authentication libraries
gem 'devise', '~> 3.5.2'
gem 'devise-async', '~> 0.9.0'
gem 'doorkeeper', '~> 2.2.0'
gem 'omniauth', '~> 1.2.2'
gem 'omniauth-bitbucket', '~> 0.0.2'
gem 'omniauth-facebook', '~> 3.0.0'
gem 'omniauth-github', '~> 1.1.1'
gem 'omniauth-gitlab', '~> 1.0.0'
gem 'omniauth-google-oauth2', '~> 0.2.0'
gem 'omniauth-kerberos', '~> 0.3.0', group: :kerberos
gem 'omniauth-saml', '~> 1.4.0'
gem 'omniauth-shibboleth', '~> 1.2.0'
gem 'omniauth-twitter', '~> 1.2.0'
gem 'omniauth_crowd'
gem 'rack-oauth2', '~> 1.2.1'

# Two-factor authentication
gem 'devise-two-factor', '~> 2.0.0'
gem 'rqrcode-rails3', '~> 0.1.7'
gem 'attr_encrypted', '~> 1.3.4'

# Browser detection
gem "browser", '~> 1.0.0'

# Extracting information from a git repository
# Provide access to Gitlab::Git library
gem "gitlab_git", '~> 7.2.20'

# LDAP Auth
# GitLab fork with several improvements to original library. For full list of changes
# see https://github.com/intridea/omniauth-ldap/compare/master...gitlabhq:master
gem 'gitlab_omniauth-ldap', '~> 1.2.1', require: "omniauth-ldap"

# Git Wiki
gem 'gollum-lib', '~> 4.0.2'

# Language detection
gem "github-linguist", "~> 4.7.0", require: "linguist"

# API
#gem 'grape', '~> 0.13.0'
gem 'grape-entity', '~> 0.4.2'
gem 'rack-cors', '~> 0.4.0', require: 'rack/cors'

# Format dates and times
# based on human-friendly examples
gem "stamp", '~> 0.6.0'

# Pagination
gem "kaminari", "~> 0.16.3"

# HAML
gem "haml-rails", '~> 0.9.0'

# Files attachments
gem "carrierwave", '~> 0.9.0'

# Drag and Drop UI
gem 'dropzonejs-rails', '~> 0.7.1'

# for aws storage
gem "fog", "~> 1.25.0"
gem "unf", '~> 0.1.4'

# Authorization
gem "six", '~> 0.2.0'

# Seed data
gem "seed-fu", '~> 2.3.5'

# Markdown and HTML processing
gem 'html-pipeline', '~> 1.11.0'
gem 'task_list', '~> 1.0.2', require: 'task_list/railtie'
gem 'github-markup', '~> 1.3.1'
gem 'redcarpet', '~> 3.3.3'
gem 'RedCloth', '~> 4.2.9'
gem 'rdoc', '~>3.6'
gem 'org-ruby', '~> 0.9.12'
gem 'creole', '~> 0.5.0'
gem 'wikicloth', '0.8.1'
gem 'asciidoctor', '~> 1.5.2'
gem 'net-ssh', '~> 3.0.1'

# Diffs
gem 'diffy', '~> 3.0.3'

# Application server
group :unicorn do
gem "unicorn", '~> 4.8.2'
gem 'unicorn-worker-killer', '~> 0.4.2'
end

# State machine
gem "state_machines-activerecord", '~> 0.3.0'
# Run events after state machine commits
gem 'after_commit_queue'

# Issue tags
gem 'acts-as-taggable-on', '~> 3.4'

# Background jobs
gem 'sinatra', '~> 1.4.4', require: nil
gem 'sidekiq', '3.3.0'
gem 'sidetiq', '~> 0.6.3'

# HTTP requests
gem "httparty", '~> 0.13.3'

# Colored output to console
gem "colorize", '~> 0.7.0'

# GitLab settings
gem 'settingslogic', '~> 2.0.9'

# Misc

gem 'version_sorter', '~> 2.0.0'

# Cache
gem "redis-rails", '~> 4.0.0'

# Campfire integration
gem 'tinder', '~> 1.10.0'

# HipChat integration
gem 'hipchat', '~> 1.5.0'

# Flowdock integration
gem "gitlab-flowdock-git-hook", "~> 1.0.1"

# Gemnasium integration
gem "gemnasium-gitlab-service", "~> 0.2"

# Slack integration
gem "slack-notifier", "~> 1.2.0"

# Asana integration
gem 'asana', '~> 0.4.0'

# FogBugz integration
gem 'ruby-fogbugz', '~> 0.2.1'

# d3
gem 'd3_rails', '~> 3.5.5'

#cal-heatmap
gem "cal-heatmap-rails", "~> 0.0.1"

# underscore-rails
gem "underscore-rails", "~> 1.4.4"

# Sanitize user input
gem "sanitize", '~> 2.0'

# Protect against bruteforcing
gem "rack-attack", '~> 4.3.0'

# Ace editor
gem 'ace-rails-ap', '~> 2.0.1'

# Keyboard shortcuts
gem 'mousetrap-rails', '~> 1.4.6'

# Detect and convert string character encoding
gem 'charlock_holmes', '~> 0.7.3'

gem "sass-rails", '~> 4.0.5'
gem "coffee-rails", '~> 4.1.0'
gem "uglifier", '~> 2.7.2'
gem 'turbolinks', '~> 2.5.0'
gem 'jquery-turbolinks', '~> 2.1.0'

gem 'addressable', '~> 2.3.8'
gem 'bootstrap-sass', '~> 3.0'
gem 'font-awesome-rails', '~> 4.2'
gem 'gitlab_emoji', '~> 0.1'
gem 'gon', '~> 6.0.1'
gem 'jquery-atwho-rails', '~> 1.3.2'
gem 'jquery-rails', '~> 3.1.3'
gem 'jquery-scrollto-rails', '~> 1.4.3'
gem 'jquery-ui-rails', '~> 4.2.1'
gem 'nprogress-rails', '~> 0.1.6.7'
gem 'raphael-rails', '~> 2.1.2'
gem 'request_store', '~> 1.2.0'
gem 'select2-rails', '~> 3.5.9'
gem 'virtus', '~> 1.0.1'

group :development do
gem "foreman"
gem 'brakeman', '3.0.1', require: false

gem "annotate", "~> 2.6.0"
gem "letter_opener", '~> 1.1.2'
gem 'quiet_assets', '~> 1.0.2'
gem 'rerun', '~> 0.10.0'
gem 'bullet', require: false
gem 'rblineprof', platform: :mri, require: false
gem 'web-console', '~> 2.0'

# Better errors handler
gem 'better_errors', '~> 1.0.1'
gem 'binding_of_caller', '~> 0.7.2'

# Docs generator
gem "sdoc", '~> 0.3.20'

# thin instead webrick
gem 'thin', '~> 1.6.1'
end

group :development, :test do
gem 'byebug', platform: :mri
gem 'pry-rails'

gem 'awesome_print', '~> 1.2.0'
gem 'fuubar', '~> 2.0.0'

gem 'database_cleaner', '~> 1.4.0'
gem 'factory_girl_rails', '~> 4.3.0'
gem 'rspec-rails', '~> 3.3.0'
gem 'spinach-rails', '~> 0.2.1'

# Prevent occasions where minitest is not bundled in packaged versions of ruby (see #3826)
gem 'minitest', '~> 5.7.0'

# Generate Fake data
gem 'ffaker', '~> 2.0.0'

gem 'capybara', '~> 2.4.0'
gem 'capybara-screenshot', '~> 1.0.0'
gem 'poltergeist', '~> 1.6.0'

gem 'teaspoon', '~> 1.0.0'
gem 'teaspoon-jasmine', '~> 2.2.0'

gem 'spring', '~> 1.3.6'
gem 'spring-commands-rspec', '~> 1.0.4'
gem 'spring-commands-spinach', '~> 1.0.0'
gem 'spring-commands-teaspoon', '~> 0.0.2'

gem 'rubocop', '~> 0.28.0', require: false
gem 'coveralls', '~> 0.8.2', require: false
gem 'simplecov', '~> 0.10.0', require: false
gem 'flog', require: false
gem 'flay', require: false
gem 'bundler-audit', require: false

gem 'benchmark-ips', require: false
#>>>>>>> abf54f230ef7ff80c0ca1baa6a3c4c3d0cbb7869
end

group :test do
gem 'shoulda-matchers', '~> 2.8.0', require: false
gem 'email_spec', '~> 1.6.0'
gem 'webmock', '~> 1.21.0'
gem 'test_after_commit', '~> 0.4.2'
gem 'sham_rack'
end

group :production do
gem "gitlab_meta", '7.0'
end

gem "newrelic_rpm", '~> 3.9.4.245'
gem 'newrelic-grape'

gem 'octokit', '~> 3.7.0'

gem "mail_room", "~> 0.6.1"

gem 'email_reply_parser', '~> 0.5.8'

## CI
gem 'activerecord-deprecated_finders', '~> 1.0.3'
gem 'activerecord-session_store', '~> 0.1.0'
gem "nested_form", '~> 0.3.2'

# OAuth
gem 'oauth2', '~> 1.0.0'


gem "rugments", "~> 1.0.0.beta8"

gem 'therubyracer'
gem 'execjs'

# Soft deletion
gem "paranoia", "~> 2.0"


+ 1029
- 0
Gemfile.lock
File diff suppressed because it is too large
View File


+ 0
- 40
Guardfile View File

@@ -1,40 +0,0 @@
# More info at https://github.com/guard/guard#readme

# guard 'rails' do
# watch('Gemfile.lock')
# watch(%r{^(config|lib)/.*})
# end
#
guard 'spork', :test_unit => true, :test_unit_env => {'RAILS_ENV' => 'test'}, :wait => 60 do
watch(%r{app/models/.+\.rb})
watch('config/application.rb')
watch('config/environment.rb')
watch('config/environments/test.rb')
watch(%r{^config/initializers/.+\.rb$})
watch('Gemfile.lock')
watch('spec/spec_helper.rb') { :rspec }
watch('test/test_helper.rb') { :test_unit }
watch(%r{features/support/}) { :cucumber }
end

guard :test, :drb => true, :all_after_pass => false, :all_on_start => false do
watch(%r{^test/.+_test\.rb$})
watch('test/test_helper.rb') { 'test' }

# Non-rails
watch(%r{^lib/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }

# Rails 4
# watch(%r{^app/(.+)\.rb}) { |m| "test/#{m[1]}_test.rb" }
# watch(%r{^app/controllers/application_controller\.rb}) { 'test/controllers' }
# watch(%r{^app/controllers/(.+)_controller\.rb}) { |m| "test/integration/#{m[1]}_test.rb" }
# watch(%r{^app/views/(.+)_mailer/.+}) { |m| "test/mailers/#{m[1]}_mailer_test.rb" }
# watch(%r{^lib/(.+)\.rb}) { |m| "test/lib/#{m[1]}_test.rb" }

# Rails < 4
watch(%r{^app/models/(.+)\.rb$}) { |m| "test/unit/#{m[1]}_test.rb" }
watch(%r{^app/controllers/(.+)\.rb$}) { |m| "test/functional/#{m[1]}_test.rb" }
watch(%r{^app/views/(.+)/.+\.erb$}) { |m| "test/functional/#{m[1]}_controller_test.rb" }
watch(%r{^app/views/.+$}) { 'test/integration' }
watch('app/controllers/application_controller.rb') { ['test/functional', 'test/integration'] }
end

+ 0
- 5
README.rdoc View File

@@ -1,5 +0,0 @@
= Redmine

Redmine is a flexible project management web application written using Ruby on Rails framework.

More details can be found in the doc directory or on the official website http://www.redmine.org

+ 0
- 7
Rakefile View File

@@ -1,7 +0,0 @@
#!/usr/bin/env rake
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require File.expand_path('../config/application', __FILE__)

RedmineApp::Application.load_tasks

+ 0
- 99
ReadMe.txt View File

@@ -1,99 +0,0 @@
===================================[2014-04-09]=================================
kw: 域名, 二级域名, subdomain, forge, course, contest
域名跳转(forge/course/contest)这几个设置在settings.yml中
但是跳转在development模式下会导致无法开发
app/models/setting.rb :165
# fixed domain url in development. tantantan's bug
if Rails.env.development?
methods.map do |m|
define_singleton_method m do; nil; end if m.to_s =~ /([a-zA-Z]+_domain)$/
end
end
程序部分链接中制定了subdomain参数,使链接在二级域名中来回跳转。
为了开发方便,使之功能在development模式下失效。
===================================[2014-04-09]=================================
kw: 菜单, 导航栏, layout
网页上方的导航条没有用Redmine::MenuManager
MenuManager的样式无法定制,菜单显示条件if中的proc执行行为没有了解
#导航栏匹配域名显示和改变
app\helper\application_helper.rb
render_dynamic_nav 方法中,利用变量,可以设置在layout中具体显示哪些条目
app\views\layouts\_base_header.html.erb
需要显示的条目,由具体的实例变量设置(在各个layout中)
===================================[2014-04-09]=================================
kw: home_path, 首页, 跳转, 二级域名, welcome
#首页根据域名匹配进入不同的页面
app\controller\welcome_controller.rb
#entry_select 放射设置二级域名所显示的首页
===================================[2014-06-06]=================================
kw: user_scores
user_scores表结构有问题,需要运行
bundle exec rake db:migrate:down VERSION=20140410021724
bundle exec rake db:migrate:up VERSION=20140410021724
===================================[2014-07-08]=================================
kw: CKEditor, 富文本, 编辑器
CKEditor插件加载方法
1.把插件文件夹拷入plugins文件夹,确保文件夹名为redmine_ckeditor
2.运行 bundle install --without development test
3.运行 rake redmine:plugins:migrate RAILS_ENV=production
4.启动服务器
5.配置CKEditor插件(Administration > Plugins > Configure)
6.把文本格式 (Administration > Settings > General > Text formatting)改为CKEditor
注意:一定要先配置CKEditor插件再见文本格式更改,不然,数据库不会生成对应记录,会报错。。
===================================[2014-07-19]=================================
kw: 首页, 定制, forge, course, contest, 排序
若遇到首页定制报错问题请尝试如下操作
如果运行迁移文件有报错与‘sort_type’相关
先运行 bundle exec rake db:migrate:down version=20140716021202 bundle exec rake db:migrate:up version=20140716021202
在按如下步骤执行,未报与之相关的则直接按如下步骤执行
1.运行 bundle exec rake db:migrate:down version=20140719080032
2.运行 bundle exec rake db:migrate:up version=20140719080032
===================================[2014-07-30]=================================
kw: 首页, 定制, forge, course, contest, 排序,image_width
undefined image_width 问题
bundle exec rake db:migrate:down version=20140725062302
bundle exec rake db:migrate:up version=20140725062302
=================================[2014-07-19]=====================================
kw: Mysql2::Error,存储过程,CALL sp_project_status_cursor();
bundle exec rake db:migrate:down version=20130828004955
bundle exec rake db:migrate:up version=20130828004955
=================================[2014-08-13]====================================
kw:配置支持的图片格式
默认支持如下格式:"bmp,jpeg,jpg,png,gif"
可在configuration.yml中修改,格式:pic_types: "bmp,jpeg,jpg,png,gif"(注意:pic_types若前面有#号需去掉)
配置完成后重启服务
=================================[2014-08-16]====================================
kw:数据迁移,project_scores表已存在
bundle exec rake db:migrate:down VERSION=20140811022947
bundle exec rake db:migrate:up VERSION=20140811022947
bundle exec rake db:migrate
bundle exec rake project_score:calculate
=================================[2014-10-17]====================================
kw:数据迁移,web_footer_oranizers表已存在
bundle exec rake db:migrate:down VERSION=20141013014908
bundle exec rake db:migrate:up VERSION=20141013014908
bundle exec rake db:migrate
kw:数据迁移,web_footer_companies表已存在
bundle exec rake db:migrate:down VERSION=20141013023400
bundle exec rake db:migrate:up VERSION=20141013023400
bundle exec rake db:migrate

+ 0
- 86
app/api/mobile/api.rb View File

@@ -1,86 +0,0 @@
#coding=utf-8
module Mobile
require_relative 'middleware/error_handler'
require_relative 'apis/auth'
require_relative 'apis/users'
require_relative 'apis/courses'
require_relative 'apis/watches'
require_relative 'apis/upgrade'
require_relative 'apis/homeworks'
require_relative 'apis/comments'
require_relative 'apis/issues'
require_relative 'apis/activities'
require_relative 'apis/whomeworks'
require_relative 'apis/newss'
require_relative 'apis/journal_for_messages'
require_relative 'apis/messages'
require_relative 'apis/blog_comments'
require_relative 'apis/new_comment'
require_relative 'apis/praise'
require_relative 'apis/resources'
require_relative 'apis/syllabuses'
require_relative 'apis/projects'
class API < Grape::API
version 'v1', using: :path
format :json
content_type :json, "application/json;charset=UTF-8"
use ActionDispatch::Session::CookieStore
use Middleware::ErrorHandler
helpers do
def logger
API.logger
end
def authenticate!
raise('Unauthorized. 用户认证失败.') unless current_user
end
def session
env['rack.session']
end
def current_user
openid = session[:wechat_openid]
if openid
uw = UserWechat.find_by_openid(openid)
return uw.user if uw
end
token = ApiKey.where(access_token: params[:token]).first
if token && !token.expired?
return User.find(token.user_id)
end
nil
end
end
mount Apis::Auth
mount Apis::Users
mount Apis::Courses
mount Apis::Watches
mount Apis::Upgrade
mount Apis::Homeworks
mount Apis::Comments
mount Apis::Issues
mount Apis::Activities
mount Apis::Whomeworks
mount Apis::Newss
mount Apis::JournalForMessages
mount Apis::Messages
mount Apis::BlogComments
mount Apis::NewComment
mount Apis::Praise
mount Apis::Resources
mount Apis::Syllabuses
mount Apis::Projects
add_swagger_documentation ({api_version: 'v1', base_path: '/api'}) if Rails.env.development?
end
end

+ 0
- 69
app/api/mobile/apis/activities.rb View File

@@ -1,69 +0,0 @@
#coding=utf-8
module Mobile
module Apis
class Activities< Grape::API
resources :activities do
desc "get user activities"
params do
requires :page, type: Integer
requires :token, type: String
requires :container_type, type: String
end
post do
begin
authenticate!
user = current_user
container_type = params[:container_type] ? params[:container_type] : "All"
if container_type == "All" || container_type == "Project"
shield_project_ids = ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{user.id} and shield_type='Project'").map(&:shield_id)
user_project_ids = (user.projects.where("status = 1").map{|project| project.id}-shield_project_ids).empty? ? "(-1)" : "(" + (user.projects.where("status = 1").map{|project| project.id}-shield_project_ids).join(",") + ")"
project_types = "('Message','Issue','Project')"
end
if container_type == "All" || container_type == "Course"
shield_course_ids = ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{user.id} and shield_type='Course'").map(&:shield_id)
user_course_ids = (user.courses.where("is_delete = 0").map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (user.courses.where("is_delete = 0").map{|course| course.id}-shield_course_ids).join(",") + ")"
course_types = "('Message','News','HomeworkCommon','Poll','Course')"
end
page = params[:page] ? params[:page] : 0
principal_types = "JournalsForMessage"
watched_user_ids = User.watched_by(user.id).count == 0 ? " " : ("," + User.watched_by(user.id).map{|u| u.id.to_s }.join(','))
user_ids = "(" + user.id.to_s + watched_user_ids + ")"
watched_user_blog_ids = Blog.select("id").where("author_id in #{user_ids}").count == 0 ? "-1" :Blog.select("id").where("author_id in #{user_ids}").map { |blog| blog.id}.join(",")
blog_ids = "(" + watched_user_blog_ids + ")"
if container_type == "Course"
activities = UserActivity.where("(container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types})").order('updated_at desc')
elsif container_type == "Project"
activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})").order('updated_at desc')
else
activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})" +
"or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}) "+
"or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{user.id}) " +
"or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})").order('updated_at desc')
end
all_count = activities.count
activities = activities.limit(10).offset(page * 10)
count = activities.count
present :data, activities, with: Mobile::Entities::Activity,user: user
present :all_count, all_count
present :count, count
present :page, page
present :status, 0
present :container_type, container_type
rescue Exception=>e
present :status, -1
present :message, e.message
end
end
end
end
end
end

+ 0
- 60
app/api/mobile/apis/auth.rb View File

@@ -1,60 +0,0 @@
#coding=utf-8

module Mobile

module Entities
class Auth < Grape::Entity
expose :token
expose :user, using: User
end
end

module Apis
class Auth < Grape::API
resource :auth do
desc "用户登录"
params do
requires :login, type: String, desc: 'Username or email'
requires :password, type: String, desc: 'Password'
end
post do
user,last_logon = ::User.try_to_login(params[:login], params[:password])
if user
::ApiKey.delete_all(user_id: user.id)
key = ::ApiKey.create!(user_id: user.id)
api_user = ::UsersService.new.show_user({id:user.id})
present :data, {token: key.access_token, user: api_user}, using: Entities::Auth
present :status, 0
else
present :message, "无效的用户名或密码"
present :status,1
end
end

desc "用户登出"
params do
requires :token, type: String
end
delete do
authenticate!
::ApiKey.delete_all(user_id: current_user.id)
{status: 0}
end

desc "忘记密码"
params do
requires :mail,type: String
end
post 'lost_password' do
us = UsersService.new
message = us.lost_password params
present :message, message
present :status, 0
end

end
end
end
end



+ 0
- 31
app/api/mobile/apis/blog_comments.rb View File

@@ -1,31 +0,0 @@
#coding=utf-8

module Mobile
module Apis
class BlogComments< Grape::API
resources :blog_comments do

desc "get special topic"
post ':id' do
begin
user = current_user

#0一级回复的更多 1 二级回复的更多
type = params[:type] || 0
page = params[:page] || 0

blog = BlogComment.find params[:id]
present :data, blog, with: Mobile::Entities::BlogComment,user: user,type: type,page: page
present :type, type
present :page, page
present :status, 0
rescue Exception=>e
present :status, -1
present :message, e.message
end
end
end
end
end
end


+ 0
- 133
app/api/mobile/apis/comments.rb View File

@@ -1,133 +0,0 @@
#coding=utf-8
module Mobile
module Apis
class Comments < Grape::API
include ApplicationHelper
resource :comments do
desc '课程通知评论'
params do
requires :token, type: String
requires :comments, type: String
end
post ':id' do
cs = CommentService.new
cs_params = {
id: params[:id],
comment: params.reject{|k,v| [:id].include?(k)}}
comments = cs.news_comments cs_params,current_user
raise "create comments failed #{comments.errors.full_messages}" if comments.new_record?
present :data, comments, with: Mobile::Entities::Comment
present :status, 0
end
desc '作业留言(教师布置的作业)'
params do
requires :token, type: String
requires :message,type: String, desc: '留言'
#optional :reference_content, type: String ,desc: '引用的内容'
#optional :reference_user_id, type: Integer,desc: '被引用的人'
end
post ':id/create_homework_message' do
cs_params = {
id: params[:id],
token: params[:token],
reference_content: params[:reference_content],
bid_message: params.reject{|k,v| [:id,:token,:reference_content].include?(k)}}
cs = CommentService.new
message = cs.homework_message cs_params,current_user
present :data, message, with: Mobile::Entities::Jours
present :status, 0
end
desc '课程留言'
params do
requires :token, type: String
requires :course_message,type: String, desc: '留言'
end
post ':id/leave_course_message' do
cs_params = {
id: params[:id],
token: params[:token],
new_form: params.reject{|k,v| [:id,:token].include?(k)}}
cs = CommentService.new
message = cs.leave_course_message cs_params,current_user
present :data, message, with: Mobile::Entities::Jours
present :status, 0
end
desc '回复留言'
params do
requires :token, type: String
requires :reference_id, type: Integer,desc: '所属留言树的根留言id(最顶层的非回复的留言,留言对象中的m_parent_id)'
requires :reference_user_id,type: Integer ,desc: '被回复的留言的作者id'
#requires :reference_message_id,type: Integer,desc: '被回复的留言的id'
requires :user_notes,type: String,desc: '留言的内容'
requires :jour_type,type: String,desc: '等于父留言的jour_type'
requires :jour_id,type:Integer, desc: '等于父留言的jour_id'
end
post ':reference_message_id/create_reply'do
cs = CommentService.new
message = cs.create_reply params,current_user
raise "create reply failed #{message.errors.full_messages}" if message.new_record?
present :data, message, with: Mobile::Entities::Jours
present :status, 0
end
desc ' 意见反馈'
params do
requires :token, type: String
requires :subject,type: String,desc: '意见'
end
post do
cs_params = {
memo: {:subject => '该贴来自手机App意见反馈' ,:content => params[:subject]},
}
cs = CommentService.new
memo,message = cs.create_feedback cs_params, current_user
raise message if memo.new_record?
present :status, 0
end
desc '课程留言列表'
params do
optional :token, type: String
optional :page,type:Integer,desc:'页数'
end
get ':id/course_message' do
cs = CommentService.new
jours = cs.course_messages params,(current_user.nil? ? User.find(2):current_user)
present :data, jours, with: Mobile::Entities::Jours
present :status, 0
end
desc '留言详情'
params do
requires :token, type: String
requires :comment_parent_id,type:Integer,desc:'留言id'
optional :course_id,type:Integer,desc:'课程id'
end
get ':comment_parent_id/comment_details' do
cs = CommentService.new
jour = cs.comment_detail params,current_user
present :data, jour, with: Mobile::Entities::Jours
present :status, 0
end
desc '通知评论列表'
params do
#requires :token, type: String
requires :notice_id,type:Integer,desc:'通知id'
optional :page,type:Integer,desc:'页码'
end
get ':notice_id/notice_comments' do
cs = CommentService.new
comments = cs.notice_comments params,current_user
present :data, comments, with: Mobile::Entities::Comment
present :status, 0
end
end
end
end
end

+ 0
- 934
app/api/mobile/apis/courses.rb View File

@@ -1,934 +0,0 @@
#coding=utf-8
module Mobile
module Apis
class Courses < Grape::API
resource :courses do
def self.get_service
CoursesService.new
end
desc "获取所有课程"
params do
optional :school_id, type: Integer, desc: '传入学校id,返回该学校课程列表'
requires :per_page_count, type: Integer, desc: '每页总数'
requires :page, type: Integer, desc: '当前页码'
optional :token, type: String
end
get do
authenticate!
cs = CoursesService.new
courses = cs.user_courses_list(current_user)
present :data, courses, with: Mobile::Entities::Course,user: current_user
present :status, 0
end

desc "获取课程动态"
params do
requires :course_count, type: Integer, desc: '每页总数'
requires :page, type: Integer, desc: '当前页码'
end
get "news" do
cs = CoursesService.new
courses = cs.news(params)
end

desc "新建课程"
#current_user当前用户对象(不是id)
# params[:course][:name]:课程名称
#params[:course][:password]:密码
#params[:course][:description]:描述
#params[:course][:is_public]:是否公开1公开,0私有
#params[:course][:open_student]:是否公开学生列表1公开,0不公开,不公开时非课程成员无法看到学生列表
#params[:course][:course_type]:暂时默认给1值。
#params[:term]:学期(秋季学期或春季学期)
#params[:time]: 年份(例:2014)
#params[:setup_time]:暂不传(貌似已经没用了)
#params[:endup_time]: 暂不传(貌似已经没用了)
#params[:class_period]:学时总数
params do
requires :token, type: String
requires :name, type: String, desc: '课程名称'
requires :password, type: String, desc: '密码'
requires :description, type: String, desc: '描述'
requires :is_public, type: Integer, desc: '是否公开 1公开 0私有'
requires :open_student, type: Integer, desc: '是否公开学生列表1公开,0不公开,不公开时非课程成员无法看到学生列表'
requires :course_type, type:Integer, desc: '暂时传1'
requires :term, type: String, desc: '学期(秋季学期或春季学期)'
requires :time, type: String, desc: '年份'
requires :class_period, type: String, desc: '学时总数'
end
post do
authenticate!
cs = CoursesService.new
cs_params = {
course: params.reject{|k,v| [:term,:time,:class_period].include?(k)},
term: params[:term],
time: params[:time],
class_period: params[:class_period]
}
courses = cs.create_course(cs_params, current_user)
present :data, courses, with: Mobile::Entities::Course,user: current_user
present :status, 0
end

desc "编辑课程"
params do
requires :token, type: String
requires :course_id, type: Integer, desc: '课程id'
requires :name, type: String, desc: '课程名称'
requires :password, type: String, desc: '密码'
requires :description, type: String, desc: '描述'
requires :is_public, type: Integer, desc: '是否公开 1公开 0私有'
requires :open_student, type: Integer, desc: '是否公开学生列表1公开,0不公开,不公开时非课程成员无法看到学生列表'
requires :course_type, type:Integer, desc: '暂时传1'
requires :term, type: String, desc: '学期(秋季学期或春季学期)'
requires :time, type: String, desc: '年份'
requires :class_period, type: String, desc: '学时总数'
end
put do
authenticate!
cs = CoursesService.new
cs_params = {
course: params.reject{|k,v| [:term,:time,:class_period].include?(k)},
term: params[:term],
time: params[:time],
class_period: params[:class_period]
}
course = ::Course.find(params[:course_id])
# 如果没有传密码过来,那就把原来的密码给上,不然会不更新
if params[:password].nil? || params[:password].blank?
cs_params[:course][:password] = course[:password]
end
cs.edit_course_authorize(current_user,course)
course = cs.edit_course(cs_params, course,current_user)
present :data, course, with: Mobile::Entities::Course,user: current_user
present :status, 0
end
post do
end

desc "加入课程"
params do
requires :token, type: String
requires :invite_code, type: String, desc: '邀请码'
requires :teacher_flag, type: Boolean
requires :assistant_flag, type: Boolean
requires :student_flag, type: Boolean
end
post "join_class" do
authenticate!

roles_ids = []
if params[:teacher_flag]
roles_ids << "9"
elsif params[:assistant_flag]
roles_ids << "7"
end

if params[:student_flag]
roles_ids << "10"
end

go_course_group = 0

if roles_ids.length <= 0
{status:-1,message:"请至少选择一个角色"}
else
cs = CoursesService.new
status = cs.join_course_roles({role: roles_ids, openid: params[:openid], invite_code: params[:invite_code]}, current_user)
{
status: status[:state],
message:CoursesService::JoinCourseError.message(status[:state]),
go_coursegroup_flag:status[:go_coursegroup_flag],
course_id:status[:course_id]
}
end
end


desc "退出课程"
params do
requires :token, type: String
end
delete ":id" do
authenticate!
cs = CoursesService.new
status = cs.exit_course({:object_id => params[:id]}, current_user)
out = {status: status}
message = case status
when 0; "退出成功"
when 1; "您不在课程中"
when 2; "您还未登录"
else; "未知错误,请稍后再试"
end
out.merge(message: message)
end

desc "搜索课程"
params do
requires :name, type: String, desc: "课程名"
optional :token, type: String
end
get 'search' do
cs = CoursesService.new
courses = cs.search_course(params,current_user.nil? ? User.find(2):current_user)
present :data, courses, with: Mobile::Entities::Course,user: current_user
present :status, 0
end

desc "课程老师列表"
params do
requires :token, type: String
requires :course_id, type: Integer, desc: "课程id"
end
get 'teachers' do

course = Course.find(params[:course_id])

cs = CoursesService.new
teachers = cs.course_teacher_or_student_list({role: '1'}, params[:course_id],current_user)

teachers.each do |m|
if m[:id] == course.tea_id
teachers.delete(m)
teachers.insert(0,m)
break
end
end

present :data, teachers, with: Mobile::Entities::User
present :status, 0
end

desc "课程学生列表"
params do
requires :token, type: String
requires :course_id, type: Integer, desc: "课程id"
end
get 'students' do
cs = CoursesService.new
students = cs.course_teacher_or_student_list({role: '2'}, params[:course_id],current_user)
present :data, students, with: Mobile::Entities::User
present :status, 0
end

desc "课程未审核列表"
params do
requires :token, type: String
requires :course_id, type: Integer, desc: "课程id"
end
get 'reviewers' do
authenticate!
cs = CoursesService.new
reviewers = cs.reviewers_list(params[:course_id])
present :data, reviewers, with: Mobile::Entities::User
present :status, 0
end

desc "课程单个未审核用户信息"
params do
requires :token, type: String
requires :course_id, type: Integer, desc: "课程id"
requires :user_id, type: Integer, desc: "用户id"
end
post 'review_member_info' do
authenticate!

cs = CoursesService.new
result = cs.get_reviewer_info(params)

present :data, result[:reviewer], with: Mobile::Entities::User
present :status,result[:status]
end

desc "处理教师或助教的身份申请"
params do
requires :token, type: String
requires :course_id, type: Integer, desc: "课程id"
requires :user_id, type: Integer, desc: "用户id"
requires :type, type: Integer, desc: "同意或拒绝"
end
post 'deal_join_apply' do
authenticate!

cs = CoursesService.new
result = cs.deal_join_apply(params,current_user)

present :status, result[:status]
present :message, result[:message]
end

desc "设置助教"
params do
requires :token,type:String
requires :user_id,type:Integer,desc: '用户id'
requires :course_id,type:Integer,desc:'课程id'
end
get 'set_user_as_assitant' do
cs = CoursesService.new
cs.set_as_assitant_teacher params
present :status, 0
end

desc "删除助教"
params do
requires :token,type:String
requires :user_id,type:Integer,desc: '用户id'
requires :course_id,type:Integer,desc:'课程id'
end
get 'del_user_as_assitant' do
cs = CoursesService.new
cs.del_assitant_teacher params
present :status, 0
end

desc "返回单个课程"
params do
requires :id, type: Integer
requires :token,type:String
end
route_param :id do
get do
# course = Course.find(params[:id])
cs = CoursesService.new
course = cs.show_course(params,current_user)

if course[:course][:is_delete] == 1
{status:-1, message: '该班级不存在或已被删除啦' }
else
present :data, course, with: Mobile::Entities::Course,user: current_user
present :status, 0
end
end
end

desc "获取课程动态"
params do
requires :id, type: Integer
requires :token, type: String
end
post 'activities' do
authenticate!

user = current_user

course_types = "('Message','News','HomeworkCommon','Poll','Course')"
activities = UserActivity.where("(container_type = 'Course' and container_id = #{params[:id]} and act_type in #{course_types})").order('updated_at desc')

page = params[:page] ? params[:page] : 0
all_count = activities.count
activities = activities.limit(10).offset(page * 10)
count = activities.count
present :data, activities, with: Mobile::Entities::Activity,user: user
present :all_count, all_count
present :count, count
present :page, page
present :status, 0
end

desc "课程作业列表"
params do
requires :token, type: String
end
get "homeworks/:id" do
cs = CoursesService.new
homeworks = cs.homework_list params,current_user
present :data, homeworks, with: Mobile::Entities::Homework,user: current_user
present :status, 0
end

desc "课程通知列表"
params do
optional :token, type: String
end
get ":course_id/news" do
cs = CoursesService.new
news = cs.course_news_list params,current_user.nil? ? User.find(2):current_user
present :data, news, with: Mobile::Entities::News
present :status, 0
end

desc "显示课程通知"
params do
optional :token, type: String
end
get "news/:id" do
cs = CoursesService.new
cs.show_course_news_authorize(current_user.nil? ? User.find(2):current_user)
news = cs.show_course_news params,current_user.nil? ? User.find(2):current_user
present :data, news, with: Mobile::Entities::News
present :status, 0
end

desc '用户课程动态'
params do
requires :token, type: String
end
get "course_dynamic/:id" do
cs = CoursesService.new
count = cs.all_course_dynamics(params,current_user)
present :data, count, with: Mobile::Entities::CourseDynamic
present :status, 0
end

desc '课程课件'
params do
requires :token, type: String
requires :course_id,type: Integer,desc: '课程id'
optional :name,type:String,desc:'课件名称可能包含的字符'
end
post ":course_id/attachments" do
cs = CoursesService.new
count = cs.course_attachments params
present :data, count, with: Mobile::Entities::Attachment,user: current_user
present :status, 0
end

desc '课程学生'
params do
requires :token,type:String
requires :course_id,type:Integer,desc: '课程id'
optional :name,type:String,desc:'学生的姓名或者登录名或者学号可能包含的字符'
end
get ":course_id/members" do
cs = CoursesService.new
count = cs.course_members params
# 我如果在学生当中,那么我将放在第一位
count.each do |m|
if m.user.id == current_user.id
count.delete m
count.unshift m
end
end
present :data, count, with: Mobile::Entities::Member
present :status, 0
end

desc '查看用户历次作业成绩'
params do
requires :token,type:String
requires :member_id,type:Integer,desc:'课程member_id'
optional :homeworkName,type:String,desc:'作业名称以及作业名称可能包含的字符'
end
get '/show_member_score/:member_id' do
cs = CoursesService.new
homeworkscore = cs.show_member_score params
present :data,homeworkscore,with: Mobile::Entities::Homeworkscore
present :status,0
end

desc '发布课程通知'
params do
requires :token,type:String
requires :course_id,type:Integer,desc:'课程id'
requires :title,type:String,desc:'通知标题'
requires :desc,type:String,desc:'通知描述'
end
post ':course_id/create_course_notice' do
cs = CoursesService.new
news = cs.create_course_notice params,current_user
present :data,news,with:Mobile::Entities::News
present :status,0
end

desc '总成绩 or 活跃度列表'
params do
requires :token,type:String
requires :course_id,type:Integer,desc:'课程id'
optional :page,type:Integer,desc:'页码'
optional :type,type:Integer,desc:'0是活跃度,1是成绩'
end
get ':course_id/students_score_list' do
cs = CoursesService.new
news = cs.students_score_list params,current_user
present :data,news[:user_list],with:Mobile::Entities::User
present :maxSize,news[:max_size]
present :status,0
end

desc '课程某次作业提交列表 并显示成绩'
params do
requires :token,type:String
requires :course_id,type:Integer,desc:'课程id'
requires :homework_id,type:Integer,desc:'作业id'
optional :page,type:Integer,desc:'页码'
end
get ':course_id/student_works_list' do
cs = CoursesService.new
student_works = cs.student_work_list params,current_user
present :data,student_works,with:Mobile::Entities::StudentWork
present :status,0
end

desc '讨论区信息'
params do
requires :token,type:String
requires :course_id,type:Integer,desc:'课程id'
optional :page,type:Integer,desc:'页码'
end
get ':course_id/board_message_list' do
cs = CoursesService.new
board_messages_list = cs.board_message_list params,current_user
present :data,board_messages_list.all,with:Mobile::Entities::Message
present :status,0
end

desc '讨论区某主题的回复列表'
params do
requires :token,type:String
requires :board_id,type:Integer,desc:'讨论区id'
requires :msg_id,type:Integer,desc:'讨论主题id'
optional :page,type:Integer,desc:'页码'
end
get ':board_id/board_message_reply_list' do
cs = Courses.get_service
board_messages_list = cs.board_message_reply_list params,current_user
present :data,board_messages_list.all,with:Mobile::Entities::Message
present :status,0
end

desc '讨论区回复'
params do
requires :token,type:String
requires :board_id,type:Integer,desc:'讨论区id'
requires :parent_id,type:Integer,desc:'本回复父id'
requires :subject,type:String,desc:'本回复主题'
requires :content,type:String,desc:'本回复内容'
requires :root_id,type:Integer,desc:'本回复根id'
requires :quote,type:String,desc:'本回复引用内容'
end
post ':board_id/board_message_reply' do
cs = Courses.get_service
board_messages = cs.board_message_reply params,current_user
present :data,board_messages,with:Mobile::Entities::Message
present :status,0
end


desc '获取测验列表'
params do
requires :token, type:String
end
get ':course_id/exercises' do
authenticate!

course = Course.find(params[:course_id])
exercises = course.exercises.where("exercise_status <> 1").reorder("created_at desc")
present :data,exercises,with:Mobile::Entities::Exercise,user: current_user
present :status,0
end

desc '删除课程'
params do
requires :token, type: String
end
post ':course_id/del' do
authenticate!
c = Course.find(params[:course_id])
# if c.members.count > 1
# {status: -1, message: '已经有成员加入,不能删除'}
# else
c.delete!
present :status,0
# end


end

desc "获取班级某成员角色信息"
params do
requires :id, type: Integer
requires :token, type: String
requires :user_id, type: Integer
end
post 'get_member_info' do
authenticate!

c = Course.find("#{params[:id]}")

my_member = c.member_principals.where("users.id=#{params[:user_id]}").first

if my_member && my_member.roles[0]
present :course_id,params[:id]
present :user_id,params[:user_id]
present :member_info,my_member, with: Mobile::Entities::ProjectMember
present :course_group_id,my_member.course_group_id
present :status, 0
else
present :status, -1
present :message, "该用户已不在班级中"
end

end

desc "修改班级某成员角色信息"
params do
requires :id, type: Integer
requires :token, type: String
requires :user_id, type: Integer
requires :teacher_flag, type: Boolean
requires :assistant_flag, type: Boolean
requires :student_flag, type: Boolean
end
post 'edit_member_role' do
authenticate!

roles_id = []

if params[:teacher_flag]
roles_id << 9
elsif params[:assistant_flag]
roles_id << 7
end

if params[:student_flag]
roles_id << 10
end

c = Course.find("#{params[:id]}")

my_member = c.member_principals.where("users.id=#{current_user.id}").first

rolesids = []
my_member.roles.each do |role|
rolesids << role.id
end

#7教辅 9教师 10学生
if c.tea_id == params[:user_id] || roles_id.length <= 0
present :status, -1
present :message,"修改失败"
elsif rolesids.include?(3) || rolesids.include?(7) || rolesids.include?(9)
cs = CoursesService.new
status = cs.modify_user_course_role params,roles_id
present :status, status
else
present :status, -1
present :message,"修改失败"
end
end

desc "发布班级通知"
params do
requires :id, type: Integer
requires :token, type: String
requires :text, type: String
requires :title, type: String
end
post ':id/publishnotice' do
authenticate!

#老师或教辅才能发通知
c = Course.find("#{params[:id]}")

my_member = c.member_principals.where("users.id=#{current_user.id}").first

roles_ids = []
my_member.roles.each do |role|
roles_ids << role.id
end
if my_member && (roles_ids.include?(7)|| roles_ids.include?(9) || roles_ids.include?(3))

tmpparams = {}
tmpparams['title'] = params[:title]
tmpparams['description'] = params[:text]
tmpparams['sticky'] = 0

news = News.new(:course => c, :author => current_user)
#render :layout => 'base_courses'
news.safe_attributes = tmpparams

news.save!

present :status, 0
else
present :status, -1
present :message,"学生不能发布通知"
end
end

desc "发布班级问题"
params do
requires :id, type: Integer
requires :token, type: String
requires :text, type: String
end
post ':id/publishissue' do
authenticate!

c = Course.find("#{params[:id]}")

boards = c.boards.includes(:last_message => :author).all
if c.boards.empty?
board = c.boards.build
board.name = "班级问答区"
board.description = c.name.to_s
board.project_id = -1
if board.save
boards = c.boards.includes(:last_message => :author).all
end
end

board = boards.first

message = Message.new
message.author = current_user
message.board = board

tmpparams = {}
tmpparams['subject'] = params[:title]
tmpparams['content'] = params[:text]

message.safe_attributes = tmpparams

message.save!

present :status, 0

end

desc "删除班级成员"
params do
requires :id, type: Integer
requires :token, type: String
requires :user_id, type: Integer
end
post ':id/deletemember' do
authenticate!

status = -1

if(current_user.id != params[:user_id].to_i)
#权限
c = Course.find("#{params[:id]}")
if c.tea_id != params[:user_id].to_i

my_member = c.member_principals.where("users.id=#{current_user.id}").first

roles_ids = []
my_member.roles.each do |role|
roles_ids << role.id
end

if my_member && (roles_ids.include?(3) || roles_ids.include?(7) || roles_ids.include?(9) )
#删除该成员
cs = CoursesService.new
status = cs.delete_course_member(c,params[:user_id].to_i,current_user)
else
status = -2
end
else
status = -3
end
else
status = -4
end

out = {status: status}
message = case status
when 0; "删除成功"
when -1; "您还未登录"
when -2; "对不起您没有权限"
when -3; "不能删除班级管理员"
when -4; "不能删除自己"
when 1; "该用户不在该班级中"
else; "未知错误,请稍后再试"
end
out.merge(message: message)
end

desc "退出班级"
params do
requires :id, type: Integer
requires :token, type: String
end
post ':id/quit' do
authenticate!

#管理员不能退
cs = CoursesService.new
c = Course.find("#{params[:id]}")

user = current_user

if c.tea_id != user.id
status = cs.exit_course({:object_id => params[:id]}, user)
else
status = 3
end
out = {status: status}
message = case status
when 0; "退出班级成功"
when 1; "您不是该班级成员"
when 2; "您还未登录"
when 3; "管理员不能退出班级"
else; "未知错误,请稍后再试"
end
out.merge(message: message)
end

desc '获取分班列表'
params do
requires :id, type: Integer
requires :token, type:String
end
get 'course_groups/:id' do
begin
authenticate!
course = Course.find(params[:id])
groups = []
groups = course.course_groups if course.course_groups
present :data,groups
present :status,0
rescue
present :status,-1
end
end

desc "加入分班"
params do
requires :id, type: Integer
requires :token, type: String
requires :course_group_id, type: Integer
end
post 'user_join_coursegroup' do
begin
authenticate!
member = Member.where(:course_id => params[:id], :user_id => current_user.id).first

raise "你还不是该班级的学生!" unless member

member.course_group_id = params[:course_group_id].to_i
member.save
present :status,0
rescue Exception=>e
present :message,e.message
present :status,-1
end
end

desc "修改分班"
params do
requires :id, type: Integer
requires :token, type: String
requires :course_group_id, type: Integer
requires :user_id, type: Integer
end
post 'user_edit_coursegroup' do
begin
authenticate!
member = Member.where(:course_id => params[:id], :user_id => params[:user_id]).first

raise "不是该班级的学生!" unless member

member.course_group_id = params[:course_group_id].to_i
member.save
present :status,0
rescue Exception=>e
present :message,e.message
present :status,-1
end
end

desc '获取分班列表带上学生'
params do
requires :id, type: Integer
requires :token, type:String
end
get 'course_groups_withstudent/:id' do
begin
authenticate!
course = Course.find(params[:id])
groups = []
groups = course.course_groups if course.course_groups
present :data,groups, with: Mobile::Entities::CourseGroup
present :status,0
rescue
present :status,-1
end
end

desc "删除分班"
params do
requires :id, type: Integer
requires :token, type: String
requires :course_group_id, type: Integer
end
post 'delete_coursegroup' do
begin
authenticate!
c = Course.find("#{params[:id]}")
my_member = c.member_principals.where("users.id=#{current_user.id}").first

roles_ids = []
my_member.roles.each do |role|
roles_ids << role.id
end

if my_member && (roles_ids.include?(3) || roles_ids.include?(7) || roles_ids.include?(9) )
else
raise "您没有该权限!"
end
CourseGroup.delete(params[:course_group_id])
present :status,0
rescue Exception=>e
present :message,e.message
present :status,-1
end
end


desc "编辑分班"
params do
requires :id, type: Integer
requires :token, type: String
end
post 'edit_coursegroup' do
begin
authenticate!
c = Course.find("#{params[:id]}")
my_member = c.member_principals.where("users.id=#{current_user.id}").first

roles_ids = []
my_member.roles.each do |role|
roles_ids << role.id
end

if my_member && (roles_ids.include?(3) || roles_ids.include?(7) || roles_ids.include?(9) )
else
raise "您没有该权限!"
end

#增加分班和修改分班名
modify_groups = params[:modify_groups]
modify_groups.each do |g|
group = CourseGroup.find(g.id)
group.name = g.id.to_s + Time.now.to_i.to_s #只能先另取个名了不然原有的两个互换的话修改不了
group.save
end

modify_groups.each do |g|
group = CourseGroup.find(g.id)
group.name = g.name
group.save
end

#增加分班和修改分班名
add_groups = params[:add_groups]
add_groups.each do |name|
group = CourseGroup.new
group.name = name
group.course_id = params[:id]
group.save
end
present :status,0
rescue Exception=>e
present :message,e.message
present :status,-1
end
end

end
end
end
end


+ 0
- 157
app/api/mobile/apis/homeworks.rb View File

@@ -1,157 +0,0 @@
#coding=utf-8

module Mobile
module Apis
class Homeworks < Grape::API

def self.get_service
HomeworkService.new
end

resources :homeworks do
desc "作业详情"
params do
requires :id, type: Integer, desc: "作业ID"
end
route_param :id do
get do
homework = Homeworks.get_service.show_homework params
present :data, homework, with: Mobile::Entities::Homework
present :status, 0
end
end

desc "我的作品列表"
params do
requires :token, type: String
end
get ':user_id/homework_attachs' do
ue = Homeworks.get_service.my_homework_list params,current_user.nil? ? User.find(2):current_user
present :data, ue,with: Mobile::Entities::Course
present :status, 0
end

# desc "启动匿评"
# params do
# requires :token, type: String
# end
# post ':id/start_anonymous_comment' do
# statue = Homeworks.get_service.start_anonymous_comment params,current_user.nil? ? User.find(2):current_user
# messages = ""
# case statue
# when 1
# messages = "启动成功"
# when 2
# messages = "启动失败,作业总数大于等于2份时才能启动匿评"
# when 3
# messages = "已开启匿评,请务重复开启"
# end
# present :data,messages
# present :status, statue
# end
#
# desc "关闭匿评"
# params do
# requires :token, type: String
# end
# post ':id/stop_anonymous_comment' do
# Homeworks.get_service.stop_anonymous_comment params,current_user.nil? ? User.find(2):current_user
# present :status, 0
# end

desc "匿评作品详情"
params do
requires :token, type: String
end
get ':homework_id/anonymous_works_show' do
works,par = Homeworks.get_service.anonymous_works_show params.merge(:id => params[:homework_id]),current_user.nil? ? User.find(2):current_user
present :data, works ,with: Mobile::Entities::HomeworkAttach
present :otherdata,par,with: Mobile::Entities::AnonymousWorksParams
present :status, 0
end

desc "作品打分"
params do
requires :token, type: String
requires :is_teacher, type: String,desc: '是否为教师(匿评作品详情返回的结果中可获取此参数的值)'
requires :is_anonymous_comments, type: String, desc: '是否为匿评(匿评作品详情返回的结果中可获取此参数的值)'
optional :stars_value, type: Integer,desc: '用户给出的评分'
optional :cur_page,type: Integer,desc: '匿评作品详情返回的结果中可获取此参数的值'
optional :cur_type, type: Integer,desc: '匿评作品详情返回的结果中可获取此参数的值'
optional :user_message, type: String, desc: '用户评论'
end

post ':homework_id/scoring' do
cs_params = {
new_form: params.reject{|k,v| [:token,:is_teacher,:is_anonymous_comments,:stars_value,:cur_page,:cur_type,:homework_id].include?(k)},
token: params[:token],
is_teacher: params[:is_teacher],
is_anonymous_comments: params[:is_anonymous_comments],
stars_value: params[:stars_value],
cur_page: params[:cur_page],
cur_type: params[:cur_type],
homework_id: params[:homework_id]
}
Homeworks.get_service.add_score_and_jour cs_params,current_user
present :status, 0
end

desc '创建作业'
params do
requires :token,type:String
requires :work_name,type:String,desc:'作业名称'
requires :work_desc,type:String,desc:'作业描述'
requires :work_deadline,type:String,desc:'截止日期'
requires :is_blind_appr,type:Integer,desc:'是否匿评'
requires :blind_appr_num,type:Integer,desc:'匿评分配数'
requires :course_id,type:Integer,desc: '课程id'
end
post 'create_home_work' do
Homeworks.get_service.create_home_work params,current_user
present :status, 0
end

desc '开启匿评'
params do
requires :token,type:String
requires :course_id,type:Integer,desc:'课程id'
requires :homework_id,type:Integer,desc:'作业id'
end
post ':homework_id/start_anonymous_comment' do
hs = Homeworks.get_service
status = hs.start_anonymous_comment params,current_user
messages = ""
case status[:status]
when 1
messages = "启动成功"
when 2
messages = "启动失败,作业总数大于等于2份时才能启动匿评"
when 3
messages = "已开启匿评,请务重复开启"
when 4
messages = "没有开启匿评的权限"
when 5
messages = "截止日期之前不可启动匿评"
end
present :data,messages
present :status,0
end

desc '关闭匿评'
params do
requires :token,type:String
requires :course_id,type:Integer,desc:'课程id'
requires :homework_id,type:Integer,desc:'作业id'
end
post ':homework_id/stop_anonymous_comment' do
hs = Homeworks.get_service
hs.stop_anonymous_comment params,current_user
message = "成功关闭"
present :data, message
present :status,0
end

end
end
end
end

+ 0
- 44
app/api/mobile/apis/issues.rb View File

@@ -1,44 +0,0 @@
#coding=utf-8
module Mobile
module Apis
class Issues< Grape::API
resources :issues do
include IssuesHelper
desc "get special issuse"
post ':id' do
begin
# authenticate!
user = current_user
#is_public true 公开 false 私有 1公开 0私有
#0一级回复的更多 1 二级回复的更多
type = params[:type] || 0
page = params[:page] || 0
is_public = 1
if type == 0
issue = Issue.find params[:id]
issue.project.is_public
present :data, issue, with: Mobile::Entities::Issue,user: user,type: type,page: page
else
jour = Journal.find params[:id]
present :data, jour, with: Mobile::Entities::Issue,user: user,type: type,page: page
end
present :type, type
present :page, page
present :is_public,is_public
present :status, 0
rescue Exception=>e
present :status, -1
present :message, e.message
end
end
end
end
end
end

+ 0
- 41
app/api/mobile/apis/journal_for_messages.rb View File

@@ -1,41 +0,0 @@
#coding=utf-8
module Mobile
module Apis
class JournalForMessages< Grape::API
resources :journal_for_messages do
desc "get special journal"
post ':id' do
begin
# authenticate!
user = current_user
#0一级回复的更多 1 二级回复的更多
type = params[:type] || 0
page = params[:page] || 0
jour = JournalsForMessage.find params[:id]
is_public = 1
if jour.jour_type == "Project"
is_public = jour.project.is_public
elsif jour.jour_type == "Course"
is_public = jour.course.is_public
end
present :data, jour, with: Mobile::Entities::Jours,user: user,type: type,page: page
present :type, type
present :page, page
present :is_public, is_public
present :status, 0
rescue Exception=>e
present :status, -1
present :message, e.message
end
end
end
end
end
end

+ 0
- 44
app/api/mobile/apis/messages.rb View File

@@ -1,44 +0,0 @@
#coding=utf-8
module Mobile
module Apis
class Messages< Grape::API
resources :messages do
desc "get special topic"
post ':id' do
begin
# authenticate!
user = current_user
#0一级回复的更多 1 二级回复的更多
type = params[:type] || 0
page = params[:page] || 0
message = Message.find params[:id]
is_public = 1
type_name = ""
if message.project
is_public = message.project.is_public
type_name = "project"
elsif message.course
is_public = message.course.is_public
type_name = "course"
end
present :data, message, with: Mobile::Entities::Message,user: user,type: type,page: page
present :type, type
present :page, page
present :is_public, is_public
present :type_name, type_name
present :status, 0
rescue Exception=>e
present :status, -1
present :message, e.message
end
end
end
end
end
end

+ 0
- 321
app/api/mobile/apis/new_comment.rb View File

@@ -1,321 +0,0 @@
#coding=utf-8

module Mobile
module Apis
class NewComment< Grape::API
include ApplicationHelper
include ApiHelper
resources :new_comment do

desc "add a new comment"
params do
requires :type, type: String
requires :content, type: String
end
post ':id' do
unless current_user
#如果当前用户不存在 则需要根据微信昵称注册一个帐号
openid = session[:wechat_openid]
raise "无法获取到openid,请在微信中打开本页面" unless openid
us = UsersService.new

access_token = session[:access_token]
refresh_token = session[:refresh_token]
if access_token.present? && refresh_token.present?
begin
refreshinfo = Wechat.api.web_refresh_access_token(refresh_token)
rescue
info = Wechat.api.web_access_token(session[:wechat_code])
openid =info["openid"]
access_token =info["access_token"]
if access_token
session[:access_token] = access_token
end
refresh_token = info["refresh_token"]
if refresh_token
session[:refresh_token] = refresh_token
end
refreshinfo = Wechat.api.web_refresh_access_token(refresh_token)
end

access_token = refreshinfo["access_token"]
refresh_token = refreshinfo["refresh_token"]
session[:access_token] = access_token
session[:refresh_token] = refresh_token

#获取用户信息
userinfo = Wechat.api.web_userinfo(access_token,openid)
Rails.logger.info "userinfo!!!!!!!!!"
Rails.logger.info userinfo
name = userinfo["nickname"]
else
name = openid[0..3]+"***"+openid.last
end

user = us.register ({:login=>openid, :mail=>"#{openid}@163.com",
:password=>"12345678", :password_confirmation=>"12345678",
:should_confirmation_password => true})
raise user.errors.full_messages.first if user.new_record?
user.update_attributes(:lastname=>name)
#自动激活
if Setting.self_registration != '3'
user.activate
user.last_login_on = Time.now
if user.save
UserStatus.create(:user_id => user.id, :changsets_count => 0, :watchers_count => 0)
end
end
UserWechat.create!(
openid: openid,
user: user,
bindtype: 1
)
end

authenticate!

## 能进来的就是已关注
## 因为取消订阅的记录被删除了
subscribe = 1 #默认未关注

status = 0
tip = 0 #0班级1项目
type = params[:type]
result = 1

#0回复 1回复的回复
reply_type = params[:reply_type]

update_id = 0

if params[:content]!="" && current_user
case type
when "HomeworkCommon"
#如果是私有的 并且不是成员则不能回复
# is_public = homework_common.course.is_public
# if is_public == 0 && !current_user.member_of_course?(homework_common.course)
# status = -1
# tip = 0
# else
# feedback = HomeworkCommon.add_homework_jour(current_user, params[:content], params[:id])
# if (feedback.errors.empty?)
# homework_common.update_column(:updated_at, Time.now)
# result = 2
# end
# end
if reply_type == nil || reply_type == 0
homework_common = HomeworkCommon.find(params[:id])
feedback = HomeworkCommon.add_homework_jour(current_user, params[:content], params[:id], params[:id])
if (feedback.errors.empty?)
homework_common.update_column(:updated_at, Time.now)
result = 2
update_id = homework_common.id
end
else
#二级回复
reply = JournalsForMessage.find params[:id].to_i
homework_common = HomeworkCommon.find reply.jour_id

options = {:notes => params[:content], :reply_id => reply.user_id,:user_id => current_user.id,:m_parent_id => params[:id].to_i,:m_reply_id => params[:id].to_i}
feedback = HomeworkCommon.add_homework_jour(current_user, params[:content], reply.jour_id, reply.jour_id, options)
if (feedback.errors.empty?)
homework_common.update_column(:updated_at, Time.now)
result = 2
update_id = homework_common.id
end
end

when "News"
# if news.project
# if news.project.is_public == false && !current_user.member_of?(news.project)
# status = -1
# tip = 1
# end
# elsif news.course
# if news.course.is_public == 0 && !current_user.member_of_course?(news.course)
# status = -1
# tip = 0
# end
# end
if status == 0
if reply_type == nil || reply_type == 0
news = News.find(params[:id])
comment = Comment.new
comment.comments = params[:content]
comment.author = current_user
if news.comments << comment
result = 2
update_id = news.id
end
else
#二级回复
comment = Comment.find(params[:id])
news = News.find comment.commented_id
new_comment = news.comments.build(:author_id => current_user.id, :reply_id => params[:id], :comments => params[:content], :parent_id => comment.id)
if new_comment.save
result = 2
update_id = news.id
end
end
end
when "Message"
# if message.project
# if message.project.is_public == false && !current_user.member_of?(message.project)
# status = -1
# tip = 1
# end
# elsif message.course
# if message.course.is_public == 0 && !current_user.member_of_course?(message.course)
# status = -1
# tip = 0
# end
# end

if status == 0
# if reply_type == nil || reply_type == 0
message = Message.find(params[:id])
board = Board.find(message.board_id)
topic = message.root
reply = Message.new
reply.author = current_user
reply.board = board
reply.content = params[:content]
reply.parent_id = params[:id]
reply.subject = "RE: #{topic.subject}"
reply.root_id = topic.id
if message.children << reply
result = 2
update_id = topic.id
end
# else
#二级回复

# end
end
when "JournalsForMessage"
# if jour.jour_type == "Project"
# if jour.project.is_public == false && !current_user.member_of?(jour.project)
# status = -1
# tip = 1
# end
# elsif jour.jour_type == "Course"
# if jour.course.is_public == 0 && !current_user.member_of_course?(jour.course)
# status = -1
# tip = 0
# end
# end

if status == 0
# if reply_type == nil || reply_type == 0
jour = JournalsForMessage.find(params[:id]).root
parent_id = params[:id]
author_id = current_user.id
reply_user_id = jour.user_id
reply_id = params[:id]
content = params[:content]
options = {:user_id => author_id,
:status => true,
:m_parent_id => parent_id,
:m_reply_id => reply_id,
:reply_id => reply_user_id,
:root_id => jour.id,
:notes => content,
:is_readed => false}
jfm = jour.user.add_jour(nil, nil, nil, options)
if jfm.errors.empty?
(JournalsForMessage.find parent_id).update_attribute(:updated_on,Time.now)
result = 2
update_id = jour.id
end
# else
#二级回复

# end
end
when 'Issue'
# if issue.project.is_public == false && !current_user.member_of?(issue.project)
# status = -1
# tip = 1
# end

if status == 0
if reply_type == nil || reply_type == 0
issue = Issue.find params[:id]
is_jour = Journal.new
is_jour.user_id = current_user.id
is_jour.notes = params[:content]
is_jour.journalized = issue
if is_jour.save
result = 2
update_id = issue.id
end
else
#二级回复
jour = Journal.find(params[:id])
issue = jour.journalized
is_jour = Journal.new
is_jour.user_id = current_user.id
is_jour.notes = params[:content]
is_jour.reply_id = params[:id]
is_jour.parent_id = params[:id]
is_jour.journalized = issue
if is_jour.save
result = 2
update_id = issue.id
end
end
end
when 'BlogComment'
if reply_type == nil || reply_type == 0
blog = BlogComment.find(params[:id]).root
blogComment = BlogComment.new
blogComment.author = current_user
blogComment.blog = blog.blog
blogComment.content = params[:content]
blogComment.title = "RE: #{blog.title}"
blogComment.root_id = blog.id
if blog.children << blogComment
result = 2
update_id = blog.id
end
else
#二级回复
blog = BlogComment.find(params[:id]).root
blogComment = BlogComment.new
blogComment.author = current_user
blogComment.blog = blog.blog
blogComment.content = params[:content]
blogComment.title = "RE: #{blog.title}"
parent = BlogComment.find params[:id]
blogComment.parent_id = params[:id] #被回复的回复
blogComment.reply_id = parent.author.id #被回复者id
blogComment.root_id = blog.id

if parent.children << blogComment
result = 2
update_id = blog.id
end

end
end
if result == 2
update_course_activity_api(type,update_id)
update_user_activity_api(type,update_id)
update_org_activity_api(type,update_id)
update_forge_activity_api(type,update_id)
update_principal_activity_api(type,update_id)
end
else
result = 3
end
present :result, result
present :status, status
present :act_id, update_id
present :tip, tip
present :subscribe,subscribe
end
end
end
end
end

+ 0
- 47
app/api/mobile/apis/newss.rb View File

@@ -1,47 +0,0 @@
#coding=utf-8
module Mobile
module Apis
class Newss< Grape::API
resources :newss do
desc "get special news"
post ':id' do
begin
# authenticate!
user = current_user
#0一级回复的更多 1 二级回复的更多
type = params[:type] || 0
page = params[:page] || 0
is_public = 1
if type == 0
news = News.find params[:id]
if news.project
is_public = news.project.is_public
elsif news.course
is_public = news.course.is_public
end
else
news = Comment.find params[:id]
end
present :data, news, with: Mobile::Entities::News,user: user,type: type,page: page
present :type, type
present :page, page
present :is_public, is_public
present :status, 0
rescue Exception=>e
Rails.logger.info "course_notice is not find!"
Rails.logger.info e
present :status, -1
present :message, e.message
end
end
end
end
end
end

+ 0
- 42
app/api/mobile/apis/praise.rb View File

@@ -1,42 +0,0 @@
#coding=utf-8

module Mobile
module Apis
class Praise< Grape::API
include ApiHelper
resources :praise do
desc "praise an activity"

params do
requires :type, type: String
requires :token, type: String
end
post ':id' do
authenticate!
obj_id = params[:id]
obj_type = params[:type]
user = current_user
pts = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",obj_id,obj_type.to_s,user.id).first
if pts.blank?
praise_or_cancel(obj_type,obj_id,user,1)
obj = PraiseTreadCache.where("object_id=? and object_type=?",obj_id,obj_type.to_s).first
num = get_activity_praise_num(obj) if !obj.blank?
else
pts.destroy if !pts.blank?
#再更新praise_tread_cache表 使相应的记录减1 当为0时删除
ptc = PraiseTreadCache.where("object_id=? and object_type=?",obj_id,obj_type.to_s).first
ptc.praise_minus(1) if !ptc.blank?
if ptc.praise_num == 0
ptc.delete
end
obj = PraiseTreadCache.where("object_id=? and object_type=?",obj_id,obj_type.to_s).first
num = !obj.blank? ? get_activity_praise_num(obj) : 0
end

present :data, num
present :status, 0
end
end
end
end
end

+ 0
- 350
app/api/mobile/apis/projects.rb View File

@@ -1,350 +0,0 @@
#coding=utf-8

module Mobile
module Apis
class Projects < Grape::API

resources :projects do
desc "获取项目列表"
params do
requires :token, type: String
end
get do
authenticate!

ps = ProjectsService.new
projects = ps.user_projects(current_user)
present :data, projects, with: Mobile::Entities::Project,user: current_user
present :status, 0
end

desc "返回单个项目"
params do
requires :id, type: Integer
requires :token,type:String
end
route_param :id do
get do
# course = Course.find(params[:id])
ps = ProjectsService.new
project = ps.show_project(params,current_user)

if project[:status] == 9
{status:-1, message: '该项目不存在或已被删除啦' }
else
present :data, project, with: Mobile::Entities::Project,user: current_user
present :status, 0
end
end
end

desc "获取项目动态"
params do
requires :id, type: Integer
requires :token, type: String
end
post 'activities' do
authenticate!

user = current_user

project_types = "('Message','Issue','Project')"
activities = UserActivity.where("(container_type = 'Project' and container_id = #{params[:id]} and act_type in #{project_types})").order('updated_at desc')

page = params[:page] ? params[:page] : 0
all_count = activities.count
activities = activities.limit(10).offset(page * 10)
count = activities.count
present :data, activities, with: Mobile::Entities::Activity,user: user
present :all_count, all_count
present :count, count
present :page, page
present :status, 0
end

desc "获取项目成员"
params do
requires :id, type: Integer
requires :token, type: String
end
post 'members' do
authenticate!

project = Project.find("#{params[:id]}")
members = project.member_principals

master_members = project.member_principals.includes(:roles, :principal).where("member_roles.role_id=3").all.sort

master_members.each do |m|
if m.user_id == project.user_id
master_members.delete(m)
master_members.insert(0,m)
break
end
end

develop_members = project.member_principals.includes(:roles, :principal).where("member_roles.role_id=4").all.sort
report_members = project.member_principals.includes(:roles, :principal).where("member_roles.role_id=5").all.sort

review_master_members = []
review_develop_members = []

my_member = project.member_principals.where("users.id=#{current_user.id}").first
if my_member && my_member.roles[0] && my_member.roles[0].id == 3
ps = ProjectsService.new

user = current_user
review_master_members = ps.get_project_review_members(project,3,user)
review_develop_members = ps.get_project_review_members(project,4,user)

end

present :master_members,master_members, with: Mobile::Entities::ProjectMember
present :develop_members,develop_members, with: Mobile::Entities::ProjectMember
present :report_members,report_members, with: Mobile::Entities::ProjectMember
present :review_master_members,review_master_members
present :review_develop_members,review_develop_members
present :status, 0
end

desc "获取项目某成员角色信息"
params do
requires :id, type: Integer
requires :token, type: String
requires :user_id, type: Integer
end
post 'get_member_info' do
authenticate!

project = Project.find("#{params[:id]}")

my_member = project.member_principals.where("users.id=#{params[:user_id]}").first

if my_member && my_member.roles[0]
present :project_id,params[:id]
present :user_id,params[:user_id]
present :member_info,my_member, with: Mobile::Entities::ProjectMember
present :status, 0
else
present :status, -1
present :message, "该用户已不在项目中"
end

end

desc "修改项目某成员角色信息"
params do
requires :id, type: Integer
requires :token, type: String
requires :user_id, type: Integer
requires :role_id, type: Integer
end
post 'edit_member_role' do
authenticate!

project = Project.find("#{params[:id]}")

my_member = project.member_principals.where("users.id=#{current_user.id}").first

#3管理 4开发 5报告
if !(my_member && my_member.roles[0] && my_member.roles[0].id == 3 ) || project.user_id == params[:user_id] || !(params[:role_id] == 3 || params[:role_id] == 4 || params[:role_id] == 5)
present :status, -1
else
ps = ProjectsService.new

status = ps.modify_user_project_role params

present :status, status
end
end

desc "新建项目"
params do
requires :token, type: String
requires :name, type: String, desc: '项目名称'
end
post 'create' do
authenticate!

ps = ProjectsService.new

status = ps.createNewProject params,current_user


present :status, 0

end

desc "加入项目"
params do
requires :token, type: String
requires :invite_code, type: String, desc: '邀请码'
requires :role_id, type: Integer, desc: '身份'
end
post "join_project" do
authenticate!

role_id = params[:role_id]

if role_id != 3 && role_id != 4 && role_id != 5
{status:-1,message:"请至少选择一个角色"}
else
ps = ProjectsService.new
status = ps.join_project({role: role_id, openid: params[:openid], invite_code: params[:invite_code]}, current_user)

{status:status, message:ProjectsService::JoinProjectError.message(status)}
end

# {status:-1, message: '该功能将在近日开放,敬请期待!' }
end

desc "项目单个未审核用户信息"
params do
requires :token, type: String
requires :project_id, type: Integer, desc: "项目id"
requires :user_id, type: Integer, desc: "用户id"
end
post 'review_member_info' do
authenticate!

ps = ProjectsService.new
result = ps.get_reviewer_info(params,current_user)
present :data, result[:reviewer], with: Mobile::Entities::User
present :status, result[:status]
end

desc "处理管理或开发的身份申请"
params do
requires :token, type: String
requires :project_id, type: Integer, desc: "项目id"
requires :user_id, type: Integer, desc: "用户id"
requires :type, type: Integer, desc: "同意或拒绝"
end
post 'deal_join_apply' do
authenticate!

ps = ProjectsService.new
result = ps.deal_join_apply(params,current_user)

present :status, result[:status]
present :message, result[:message]
end

desc "发布项目帖子"
params do
requires :id, type: Integer
requires :token, type: String
requires :text, type: String
end
post ':id/publishnote' do
authenticate!

project = Project.find("#{params[:id]}")

boards = project.boards.includes(:last_message => :author).all
if project.boards.empty?
board = project.boards.build
board.name = "项目讨论区"
board.description = project.name.to_s
board.course_id = -1
if board.save
boards = project.boards.includes(:last_message => :author).all
end
end

board = boards.first

message = Message.new
message.author = current_user
message.board = board

tmpparams = {}
tmpparams['subject'] = params[:title]
tmpparams['content'] = params[:text]

message.safe_attributes = tmpparams

message.save!

present :status, 0

end

desc "删除项目成员"
params do
requires :id, type: Integer
requires :token, type: String
requires :user_id, type: Integer
end
post ':id/deletemember' do
authenticate!

status = -1

if(current_user.id != params[:user_id].to_i)
#权限
project = Project.find("#{params[:id]}")
if project.user_id != params[:user_id].to_i

my_member = project.member_principals.where("users.id=#{current_user.id}").first

roles_ids = []
my_member.roles.each do |role|
roles_ids << role.id
end

if my_member && roles_ids.include?(3)
#删除该成员
ps = ProjectsService.new
status = ps.project_delete_member(project,params[:user_id].to_i,current_user)
else
status = -2
end
else
status = -3
end
else
status = -4
end

out = {status: status}
message = case status
when 0; "删除成功"
when 1; "该用户不在该项目中"
when -1; "您还未登录"
when -2; "您没有权限"
when -3; "不能删除项目创建者"
when -4; "不能删除自己"
else; "未知错误,请稍后再试"
end
out.merge(message: message)
end

desc "退出项目"
params do
requires :id, type: Integer
requires :token, type: String
end
post ':id/quit' do
authenticate!

project = Project.find("#{params[:id]}")

ps = ProjectsService.new
status = ps.exit_project(project,current_user)

out = {status: status}
message = case status
when 0; "退出项目成功"
when -3; "您不是该项目成员"
when -1; "您还未登录"
when -2; "项目创建者不能退出项目"
else; "未知错误,请稍后再试"
end
out.merge(message: message)
end

end
end
end
end

+ 0
- 119
app/api/mobile/apis/resources.rb View File

@@ -1,119 +0,0 @@
#coding=utf-8
module Mobile
module Apis
class Resources < Grape::API

resource :resources do

desc '获取所有课件'
params do
requires :token, type: String
requires :page, type: Integer
end
post do
authenticate!
page = params[:page] ? params[:page] : 0

rs = ResourcesService.new
# data = current_user.course_attachments
data = rs.all_course_attachments current_user
all_count = data.count
data = data.limit(10).offset(page * 10)
count = data.count

present :data, data, with: Mobile::Entities::Attachment,user: current_user
present :all_count, all_count
present :count, count
present :page, page
present :status, 0

end



desc '获取所有作业'
params do
requires :token, type: String
requires :page, type: Integer
end
post 'homeworks' do
authenticate!

page = params[:page] ? params[:page] : 0

rs = ResourcesService.new
homeworks = rs.all_homework_commons current_user

all_count = homeworks.count
homeworks = homeworks.limit(10).offset(page * 10)
count = homeworks.count

present :data, homeworks, with: Mobile::Entities::Homework,user: current_user
present :all_count, all_count
present :count, count
present :page, page
present :status, 0

end

desc '获取所有测验'
params do
requires :token, type: String
requires :page, type: Integer
end
post 'exercises' do
authenticate!

page = params[:page] ? params[:page] : 0

rs = ResourcesService.new
exercises = rs.all_exercises current_user
all_count = exercises.count
exercises = exercises.limit(10).offset(page * 10)
count = exercises.count

present :data, exercises, with: Mobile::Entities::Exercise,user: current_user
present :all_count, all_count
present :count, count
present :page, page
present :status, 0
end


desc '发送资源'
params do
requires :token, type: String
requires :course_ids, type: Array[Integer]
requires :send_id, type: Integer
requires :send_type, type: Integer
end
post 'send' do
authenticate!

rs = ResourcesService.new

ori = nil
flag = false
save_message = nil

case params[:send_type]
when 1
ori, flag, save_message = rs.send_resource_to_course(current_user,params)
when 2
ori, flag, save_message = rs.send_homework_to_course(current_user,params)
when 3
ori, flag, save_message = rs.send_exercise_to_course(current_user,params)
end

if flag
present :status, 0
else
{status: -1, message: save_message.first}
end
end

end

end
end
end

+ 0
- 103
app/api/mobile/apis/syllabuses.rb View File

@@ -1,103 +0,0 @@
#coding=utf-8

module Mobile
module Apis
class Syllabuses < Grape::API

resources :syllabuses do
desc "获取大纲列表"
params do
requires :token, type: String
end
get do
authenticate!

cs = SyllabusesService.new
courses = cs.user_syllabus(current_user)
present :data, courses, with: Mobile::Entities::Syllabus,user: current_user
present :status, 0
end

desc "获取某个大纲"
params do
requires :token, type: String
end
get ':id' do
authenticate!

ss = SyllabusesService.new

sy = ::Syllabus.find(params[:id])

result = {:title=>sy.title, :id=>sy.id , :user_id=>sy.user_id,:courses=>sy.courses.not_deleted}

present :data, result, with: Mobile::Entities::Syllabus,user: current_user
present :status, 0
end

desc "获取新建大纲的权限"
params do
requires :token, type: String
end
post 'auth' do
authenticate!

auth = 0

if (current_user.user_extensions && current_user.user_extensions.identity == 0 && current_user.allowed_to?(:add_course, nil, :global => true))
auth = 1
end

present :auth, auth
end

desc "新建大纲"
params do
requires :token, type: String
requires :title, type: String, desc: '大纲标题'
requires :courses, type: Array[String], desc: '课程名'
end
post do
authenticate!

ss = SyllabusesService.new

sy = ss.create(current_user, params[:title],
params[:courses].map{|c| {name: c} })

if sy.new_record?
{status:-1, message: '创建大纲失败' }
else
present :data, sy, with: Mobile::Entities::Syllabus,user: current_user
present :status, 0
end

end

desc '编辑大纲'
params do
requires :token, type: String
requires :title, type: String, desc: '大纲标题'
# requires :add_courses, type: Array[String], desc: '课程名'
# requires :modify_courses, type: Array[Integer,String], desc: '课程名'
end
post ':id/edit' do

authenticate!

ss = SyllabusesService.new

#修改课程大纲
status = ss.edit(current_user, params)

if status == -1
{status:status, message: '修改课程信息失败' }
else
present :status, status
end
end
end

end
end
end

+ 0
- 29
app/api/mobile/apis/upgrade.rb View File

@@ -1,29 +0,0 @@
#coding=utf-8

module Mobile
module Apis
class Upgrade < Grape::API
include ApplicationHelper
resource :upgrade do
desc "get update info"
params do
requires :platform, type: String, desc: '平台名,android, ios'
end
get do
@current_version = ::PhoneAppVersion.reorder('created_at desc').first
attachment = @current_version.attachments.first
if attachment.nil?
raise '未发现客户端!'
end
url = "http://" + Setting.host_name + "/attachments/download/" + attachment.id.to_s + "/" + attachment.filename
{
version: @current_version.version,
url: url,
desc: @current_version.description
}
end
end

end
end
end

+ 0
- 320
app/api/mobile/apis/users.rb View File

@@ -1,320 +0,0 @@
#coding=utf-8
module Mobile
module Apis
class Users < Grape::API
resource :users do

desc "我的资料"
params do
requires :token, type: String
end

get 'get_userinfo' do
authenticate!
present :data, current_user, with: Mobile::Entities::User
present :status, 0
end

desc "上传头像"
params do
requires :token, type: String
requires :imgdata, type: String
end

post 'upload_head' do
authenticate!
#直接生成头像
dirPath = "public/images/avatars/User"

fileDir = dirPath + "/"+current_user.id.to_s
imgdata = Base64.decode64(params[:imgdata].split(",")[1])
if imgdata.length > 1024*1024
present :message,"上传图片不能超过1M"
present :status, -1
else
begin
File.open(fileDir,'wb'){ |f| f.write(imgdata) }
present :status, 0
rescue
present :message,"上传失败"
present :status, -1
end
end
end

desc "解除绑定"
params do
requires :token, type: String
end

post 'user_unbind' do
authenticate!

user = current_user
uw = user.user_wechat

us = UsersService.new
us.wechat_unbind user.user_wechat

present :status, 0
end

desc "查询是否已绑定"
params do
requires :openid, type: String, desc: 'wechat openid'
end
post 'isbind' do
openid = params[:openid]
uw = UserWechat.where(openid: openid).first
raise "还未绑定trustie帐户" unless uw

user = uw.user
::ApiKey.delete_all(user_id: user.id)
key = ::ApiKey.create!(user_id: user.id)
present status: 0, token: key.access_token
end

desc "绑定微信用户"
params do
requires :login, type: String, desc: 'username'
requires :password, type: String, desc: 'password'
end
post 'wxbind' do
openid = session[:wechat_openid]
logger.debug "openid ============== #{openid}"
raise "无法获取到openid,请在微信中打开本页面" unless openid
uw = UserWechat.where(openid: openid).first
raise "此微信号已绑定用户(#{uw.user.login}), 不能重复绑定" if uw && uw.real?

user, last_login_on = User.try_to_login(params[:login], params[:password])
raise "用户名或密码错误,请重新输入" unless user
#补全用户信息

raise "此用户已经绑定过公众号, 请换一个帐户试试" if user.user_wechat

if uw && !uw.real?
uw.migrate_user(user)
else
UserWechat.create!(
openid: openid,
user: user
)
end

ws = WechatService.new
ws.binding_succ_notice(user.id, "您已成功绑定Trustie平台。", user.show_name+"("+user.login+")", Time.now.strftime("%Y-%m-%d"))
present status: 0, message: '您已成功绑定Trustie平台'
end

desc "注册用户"
params do
requires :login, type: String, desc: 'username'
requires :mail, type: String, desc: 'mail'
requires :password, type: String, desc: 'password'
end
post do
openid = session[:wechat_openid]
logger.debug "openid ============== #{openid}"
raise "无法获取到openid,请在微信中打开本页面" unless openid

uw = UserWechat.where(openid: openid).first
raise "此微信号已绑定用户(#{uw.user.login}), 不能重复绑定" if uw && uw.real?
us = UsersService.new
user = us.register params.merge(:password_confirmation => params[:password],
:should_confirmation_password => true)
raise user.errors.full_messages.first if user.new_record?
#自动激活
if Setting.self_registration != '3'
# user = automatically_register(user)
user.activate
user.last_login_on = Time.now
if user.save
UserStatus.create(:user_id => user.id, :changsets_count => 0, :watchers_count => 0)
end
end

if uw && !uw.real?
user.update_attributes(:lastname=>uw.user[:lastname])
uw.migrate_user(user)
else
UserWechat.create!(
openid: openid,
user: user
)
end

ws = WechatService.new
ws.binding_succ_notice(user.id, "您已成功绑定Trustie平台。", user.show_name+"("+user.login+")", Time.now.strftime("%Y-%m-%d"))
present :data, user, with: Mobile::Entities::User
present :status, 0
end

desc "显示用户"
params do
requires :id, type: Integer
end
route_param :id do
get do
us = UsersService.new
ue = us.show_user params
present :data, ue,with: Mobile::Entities::User
present :status, 0
end
end

desc "修改用户"
params do
requires :token, type: String
#optional :file, type: File, desc: 'avatar'
optional :occupation, type: String
optional :brief_introduction, type: String
optional :province, type: String
optional :city, type: String
optional :gender, type: Integer
end
put ':id' do
authenticate!
us = UsersService.new
ue = us.edit_user params.merge(id: current_user.id)
present :data, ue,with: Mobile::Entities::User
present :status, 0
end

desc '获取用户课程'
params do
optional :token, type: String
end

get ':id/courses' do
us = UsersService.new
ue = us.user_courses_list params,current_user.nil? ? User.find(2):current_user
present :data, ue,with: Mobile::Entities::Course
present :status, 0
end


desc '修改密码'
params do
requires :token, type: String
requires :password, type:String , desc: '原密码'
requires :new_password, type: String, desc: '新密码'
end
post 'password' do
authenticate!
us = UsersService.new
user = us.change_password params.merge(current_user_id: current_user.id,
new_password_confirmation: params[:new_password])
present :data, user, with: Mobile::Entities::User
present :status, 0
end

desc "用户搜索"
params do
requires :name, type: String, desc: '用户名关键字'
requires :search_by, type: String,desc: '搜索依据:0 登录名,1 用户名,2 邮箱,3 登录名和姓名'
optional :is_search_assitant,type:Integer,desc:'是否搜索注册用户来作为助教'
optional :course_id,type:Integer,desc: '课程id,搜索注册用户不为该课程教师的其他用户'
optional :user_id,type:Integer,desc:'用户id'
end
get 'search/search_user' do
us = UsersService.new
user = us.search_user params
present :data, user, with: Mobile::Entities::User
present :status, 0
end

desc "用户留言"
params do
requires :token, type: String
requires :user_id, type: Integer,desc: '被留言的用户id'
requires :page,type:Integer,desc:'请求数据的页码'
end
get ':user_id/messages' do
us = UsersService.new
jours = us.get_all_messages params
present :data,jours,with:Mobile::Entities::Jours
present :status,0
end

desc "回复用户留言"
params do
requires :token, type: String
requires :user_id, type: Integer,desc: '被留言的用户id'
requires :content,type:String,desc:'留言内容'
requires :ref_user_id,type:Integer,desc:'被回复的用户id'
requires :parent_id,type:Integer,desc:'留言父id'
requires :ref_message_id,type:Integer,desc:'引用消息id'
optional :type,type:Integer,desc:'回复类型'
optional :course_id,type:Integer,desc:'课程id'
end
post ':user_id/reply_message' do
us = UsersService.new
jours = us.reply_user_messages params,current_user
present :status,0
end

desc "给用户留言"
params do
requires :token, type: String
requires :user_id, type: Integer,desc:'被留言的用户id'
requires :content, type: String,desc:'留言内容'
end
post ':user_id/leave_message' do
us = UsersService.new
us.leave_message params,current_user
present :data,0
end

desc "与我相关"
params do
requires :token, type: String
requires :page,type:Integer,desc:'页码'
end
get ':user_id/all_my_dynamic' do
us = UsersService.new
my_jours = us.reply_my_messages params,current_user
present :data,my_jours,with:Mobile::Entities::Jours
present :status,0
end

desc "修改我的资料"

params do
requires :token, type: String
requires :lastname, type: String
requires :sex, type: Integer
end

post 'edit_userinfo' do
authenticate!
user = current_user
status = 0
message = ""

#昵称 不能超过30个字符
if params[:lastname].length > 30 then
message = "姓名不能超过30个字符!"
status = -1
end

if status == 0
user.lastname = params[:lastname]
user.update_attribute(:lastname, params[:lastname])
se = user.extensions
se.update_attribute(:gender, params[:sex])
end

if status == 0
present :data, current_user, with: Mobile::Entities::User
present :status, 0
else
present :status, -1
present :message, message
end
end
end
end
end
end



+ 0
- 49
app/api/mobile/apis/watches.rb View File

@@ -1,49 +0,0 @@
#coding=utf-8
module Mobile
module Apis
class Watches < Grape::API
resource :watches do

desc "获取所有关注"
params do
requires :token, type: String
end
get do
authenticate!
us = UsersService.new
ws = us.user_watcher(id: current_user.id)
present :data, ws, with: Mobile::Entities::User
present :status, 0
end


desc "关注某人"
params do
requires :token, type: String
requires :object_id, type: Integer, desc: '关注的用户的id'
end
post do
authenticate!
ws = WatchesService.new
o = ws.watch(params.merge({current_user_id:current_user.id, object_type:'user' }) )
present :data, o, with: Mobile::Entities::User
present :status, 0
end


desc "取消关注"
params do
requires :token, type: String
requires :object_id, type: Integer, desc: '取消关注的用户的id'
end
delete do
authenticate!
ws = WatchesService.new
ws.unwatch(params.merge({current_user_id:current_user.id, object_type:'user' }) )
{status: 0}
end

end
end
end
end

+ 0
- 40
app/api/mobile/apis/whomeworks.rb View File

@@ -1,40 +0,0 @@
#coding=utf-8
module Mobile
module Apis
class Whomeworks< Grape::API
resources :whomeworks do
desc "get one homework"
post ':id' do
begin
# authenticate!
user = current_user
#0一级回复的更多 1 二级回复的更多
type = params[:type] || 0
page = params[:page] || 0
is_public = 1
if type == 0
homework = HomeworkCommon.find params[:id]
is_public = homework.course.is_public
present :data, homework, with: Mobile::Entities::Whomework,user: user,type: type,page: page,comment_type: "homework"
else
jour = JournalsForMessage.find params[:id]
present :data, jour, with: Mobile::Entities::Jours,user: user,type: type,page: page,comment_type: "homework"
end
present :type, type
present :page, page
present :is_public, is_public
present :status, 0
rescue Exception=>e
present :status, -1
present :message, e.message
end
end
end
end
end
end

+ 0
- 195
app/api/mobile/entities/activity.rb View File

@@ -1,195 +0,0 @@
# encoding: utf-8
module Mobile
module Entities
class Activity <Grape::Entity
include ApplicationHelper
include ApiHelper
def self.act_expose(f)
expose f do |ac,opt|
if ac.is_a?(Hash) && ac.key?(f)
ac[f]
elsif ac.is_a?(::UserActivity)
if ac.respond_to?(f)
ac.send(f)
else
case f
when :user_act
if ac.act_type == "Project"
ac unless ac.nil?
else
ac.act unless ac.nil? || ac.act.nil?
end
when :reply_count
if ac.act_type == "HomeworkCommon"
ac.nil? || ac.act.nil? ? 0 : ac.act.journals_for_messages.count
elsif ac.act_type == "News"
ac.nil? || ac.act.nil? ? 0 : ac.act.comments.count
elsif ac.act_type == "Message" || ac.act_type == "BlogComment" || ac.act_type == "JournalsForMessage"
className = ac.act_type.classify.constantize
# all_comments = []
# ac.nil? || ac.act.nil? ? 0 : get_all_children(all_comments, ac.act).count
ac.nil? || ac.act.nil? ? 0 : className.where("root_id = #{ac.act.id}").count
elsif ac.act_type == "Issue"
ac.nil? || ac.act.nil? ? 0 : ac.act.journals.where("notes is not null and notes != ''").count
end
when :subject
if ac.act_type == "HomeworkCommon"
ac.act.name unless ac.nil? || ac.act.nil?
elsif ac.act_type == "News" || ac.act_type == "BlogComment"
ac.act.title unless ac.nil? || ac.act.nil?
elsif ac.act_type == "Message" || ac.act_type == "Issue"
ac.act.subject unless ac.nil? || ac.act.nil?
elsif ac.act_type == "JournalsForMessage"
ac.act.private == 0 ? "留言" : "私信" unless ac.nil? || ac.act.nil?
elsif ac.act_type == "Poll"
ac.act.polls_name unless ac.nil? || ac.act.nil?
end
when :description
if ac.act_type == "HomeworkCommon" || ac.act_type == "Issue" || ac.act_type == "News"
strip_html(ac.act.description) unless ac.nil? || ac.act.nil?
elsif ac.act_type == "Message" || ac.act_type == "BlogComment"
strip_html(ac.act.content) unless ac.nil? || ac.act.nil?
elsif ac.act_type == "JournalsForMessage"
strip_html(ac.act.notes) unless ac.nil? || ac.act.nil?
elsif ac.act_type == "Poll"
ac.act.polls_description unless ac.nil? || ac.act.nil?
end
when :latest_update
time_from_now ac.updated_at unless ac.nil?
when :praise_count
if ac.act_type == "HomeworkCommon" || ac.act_type == "News" || ac.act_type == "Message" || ac.act_type == "BlogComment" || ac.act_type == "JournalsForMessage" || ac.act_type == "Issue"
ac.nil? || ac.act.nil? ? 0 : get_activity_praise_num(ac.act)
end
#when :homework_common_detail_manual
# if ac.act_type == "HomeworkCommon"
# ac.act.homework_detail_manual unless ac.nil? || ac.act.nil? || ac.act.homework_detail_manual.nil?
# end
when :course_project_name
if ac.container_type == "Course"
name = (get_course(ac.container_id)).name
name
elsif ac.container_type == "Project"
name = (get_project(ac.container_id)).name
name
elsif ac.container_type == "Blog"
"发表博客"
end
when :syllabus_title
if ac.container_type == "Course"
course = get_course(ac.container_id)
name = course.syllabus.nil? ? "":course.syllabus.title
name
end
when :course_project_id
if ac.container_type == "Course"
ac.container_id
elsif ac.container_type == "Project"
ac.container_id
end
when :activity_type_name
if ac.container_type == "Course"
case ac.act_type
when "HomeworkCommon"
"班级作业"
when "News"
"班级通知"
when "Message"
"班级讨论区"
when "Poll"
"班级问卷"
when "Course"
"班级"
end
elsif ac.container_type == "Project"
case ac.act_type
when "Issue"
"项目问题"
when "Message"
"项目讨论区"
when "Project"
"项目"
end
end
when :homework_commit_count
if ac.act_type == "HomeworkCommon"
ac.act.student_works.has_committed.count
end
when :last_commit_info
if ac.act_type == "HomeworkCommon"
if ac.act.student_works.has_committed.count > 0
lc = ac.act.student_works.has_committed.reorder("commit_time desc").first
{:lasttime=>time_from_now(lc.commit_time), :lastname=>lc.user.show_name}
end
end
when :last_score_info
if ac.act_type == "HomeworkCommon"
if ac.act.student_works.has_committed.count > 0
sw_id = "("+ac.act.student_works.map{|sw| sw.id}.join(",")+")"
student_work_scores = StudentWorksScore.where("student_work_id in #{sw_id} and score is not null").reorder("created_at desc")
unless student_work_scores.empty?
last_score = student_work_scores.first
{:lasttime=>time_from_now(last_score.created_at), :lastname=>last_score.user.show_name}
end
end
end
end
end
end
end
end
expose :act_type #缺陷/作业/讨论区/留言等类型
expose :act_id
expose :id
expose :container_type #课程/项目/博客/个人
expose :author, using: Mobile::Entities::User do |a, opt| #用户信息
if a.is_a? ::UserActivity
if a.act_type == "Project"
get_user(get_project(a.act_id).user_id)
elsif !a.act.nil?
if a.act_type == 'Issue' || a.act_type == 'News' || a.act_type == 'Message' || a.act_type == 'BlogComment'
a.act.author
elsif a.act_type == 'HomeworkCommon' || a.act_type == 'Poll' || a.act_type == 'JournalsForMessage'
a.act.user
elsif a.act_type == 'Course'
a.act.teacher
end
end
end
end
expose :homework_common_detail , using: Mobile::Entities::Whomework do |a, opt| #作业相关信息
if a.act_type == "HomeworkCommon"
a.act
end
end
expose :issue_detail, using: Mobile::Entities::Issue do |a, opt| #缺陷信息
if a.act_type == "Issue"
a.act
end
end
act_expose :reply_count #回复数
act_expose :praise_count #点赞数
#act_expose :user_act #某个动态
act_expose :subject #标题
act_expose :description #描述
act_expose :latest_update #最新更新时间
act_expose :course_project_id #课程/项目ID
act_expose :course_project_name #课程/项目名字
act_expose :syllabus_title #课程名字
act_expose :activity_type_name #课程问答区/项目缺陷等
act_expose :homework_commit_count #作品提交数
act_expose :last_commit_info #最近提交信息
act_expose :last_score_info #最近评阅信息
expose :has_praise , if: lambda { |instance, options| options[:user] } do |instance, options|
if instance.act_type == "HomeworkCommon" || instance.act_type == "News" || instance.act_type == "Message" || instance.act_type == "BlogComment" || instance.act_type == "JournalsForMessage" || instance.act_type == "Issue"
has_praise = false
current_user = options[:user]
obj = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",instance.act_id,instance.act_type.to_s,current_user.id)
has_praise = obj.empty? ? false : true
has_praise
end
end
end
end
end

+ 0
- 36
app/api/mobile/entities/anonymous_works_params.rb View File

@@ -1,36 +0,0 @@
module Mobile
module Entities
#匿评作品页面相关参数
class AnonymousWorksParams < Grape::Entity
def self.anonymous_works_params_expose(field)
expose field do |f,opt|
if f.is_a?(Hash) && f.key?(field)
f[field]
elsif f.is_a?(Hash) && !f.key?(field)
end
end
end
anonymous_works_params_expose :is_teacher
anonymous_works_params_expose :m_score
anonymous_works_params_expose :is_anonymous_comments
anonymous_works_params_expose :cur_type
anonymous_works_params_expose :cur_page
expose :jours ,using: Mobile::Entities::Jours do |f, opt|
if f.is_a?(Hash) && f.key?(:jours)
f[:jours]
end
end
expose :teacher_stars,using: Mobile::Entities::HomeworkJours do |f, opt|
if f.is_a?(Hash) && f.key?(:teacher_stars)
f[:teacher_stars]
end
end
expose :student_stars , using: Mobile::Entities::HomeworkJours do |f, opt|
if f.is_a?(Hash) && f.key?(:student_stars)
f[:student_stars]
end
end
end
end
end

+ 0
- 58
app/api/mobile/entities/attachment.rb View File

@@ -1,58 +0,0 @@
module Mobile
module Entities
class Attachment < Grape::Entity
include Redmine::I18n
include ActionView::Helpers::NumberHelper
include ApplicationHelper
def self.attachment_expose(field)
expose field do |f,opt|
if f.is_a?(Hash) && f.key?(field)
f[field]
elsif f.is_a?(::Attachment)
if f.respond_to?(field)
if field == :created_on
format_time(f.send(field))
else
f.send(field)
end
else
case field
when :download_url
"attachments/download/#{f.try(:id)}"
when :file_dir
"attachments/download/" << f.send(:id).to_s << '/'
when :attafile_size
(number_to_human_size(f.filesize)).gsub("ytes", "").to_s
when :coursename
f.try(:course).try(:name) || ''
when :syllabus_title
f.try(:course).try(:syllabus).try(:title) || ''
when :course_id
f.try(:course).try(:id) || 0
end
end
end
end
end
attachment_expose :id
attachment_expose :filename
attachment_expose :description
attachment_expose :downloads
attachment_expose :quotes
attachment_expose :created_on
attachment_expose :file_dir
attachment_expose :attafile_size
attachment_expose :coursename #所属班级名
attachment_expose :syllabus_title #所属班级名
attachment_expose :course_id #所属班级名
expose :current_user_is_teacher, if: lambda { |instance, options| options[:user] } do |instance, options|
current_user = options[:user]
current_user_is_teacher = false
current_user_is_teacher = is_course_teacher(current_user,instance.course)
current_user_is_teacher
end
attachment_expose :download_url
end
end
end

+ 0
- 139
app/api/mobile/entities/blog_comment.rb View File

@@ -1,139 +0,0 @@
module Mobile
module Entities
class BlogComment < Grape::Entity
include ApplicationHelper
include ApiHelper
def self.blog_comment_expose(f)
expose f do |u,opt|
if u.is_a?(Hash) && u.key?(f)
u[f]
elsif u.is_a?(::BlogComment)
if u.respond_to?(f)
if f == :created_at
format_time( u.send(f))
else
u.send(f)
end
else
case f
when :praise_count
get_activity_praise_num(u)
when :lasted_comment
time_from_now(u.created_at)
when :act_type
'BlogComment'
when :act_id
u.id
when :comment_count
# u.children.count
all_comments = []
get_all_children(all_comments, u).count
end
end
end

end
end

expose :user, using: Mobile::Entities::User do |c, opt|
if c.is_a?(::BlogComment)
c.author
end
end
blog_comment_expose :act_type
blog_comment_expose :act_id
blog_comment_expose :blog_id
blog_comment_expose :title
blog_comment_expose :content
blog_comment_expose :comment_count
blog_comment_expose :created_at
blog_comment_expose :lasted_comment
blog_comment_expose :id
blog_comment_expose :locked
blog_comment_expose :praise_count
expose :all_children, using:Mobile::Entities::BlogComment do |c,opt|
if c.is_a? (::BlogComment)
if !opt[:children]
if c.parent.nil? && opt[:type] == 0
opt[:children] = true
all_comments = []
tStart = opt[:page]*5
tEnd = (opt[:page]+1)*5 - 1

all_comments = get_all_children(all_comments, c)[tStart..tEnd]
all_comments
end
end
end
end
expose :has_praise, if: lambda { |instance, options| options[:user] } do |instance, options|
has_praise = false
current_user = options[:user]
obj = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",instance.id,instance.class.to_s,current_user.id)
has_praise = obj.empty? ? false : true
has_praise
end

expose :parents_count, if: lambda { |instance, options| options[:user] } do |instance, options|
parents_reply = []
parents_reply = get_reply_parents_no_root(parents_reply, instance)
parents_reply.count
end

expose :parents_reply_bottom, using:Mobile::Entities::BlogComment do |c,opt|
if c.is_a? (::BlogComment)
#取二级回复的底楼层
parents_reply = []
parents_reply = get_reply_parents_no_root(parents_reply, c)
if parents_reply.count > 0 && !opt[:bottom]
if opt[:type] == 1
# opt[:bottom] = true
# parents_reply[opt[:page]..opt[:page]]
else
opt[:bottom] = true
parents_reply[0..0]
end
else
[]
end
end
end

expose :parents_reply_top, using:Mobile::Entities::BlogComment do |c,opt|
if c.is_a? (::BlogComment)
#取二级回复的顶楼层
parents_reply = []
parents_reply = get_reply_parents_no_root(parents_reply, c)
if parents_reply.count > 2 && !opt[:top]
if opt[:type] == 1
opt[:top] = true
tStart = (opt[:page]-1)*5+2
tEnd = (opt[:page])*5+2 - 1

if tEnd >= parents_reply.count - 1
tEnd = parents_reply.count - 2
end

if tStart <= parents_reply.count - 2
parents_reply = parents_reply.reverse[tStart..tEnd]
parents_reply.reverse
else
[]
end
else
opt[:top] = true
parents_reply = parents_reply.reverse[0..1]
parents_reply.reverse
end
elsif parents_reply.count == 2 && !opt[:top]
opt[:top] = true
parents_reply = parents_reply.reverse[0..0]
parents_reply.reverse
else
[]
end
end
end
end
end
end

+ 0
- 30
app/api/mobile/entities/comment.rb View File

@@ -1,30 +0,0 @@
module Mobile
module Entities
class Comment < Grape::Entity
include Redmine::I18n
def self.comment_expose(field)
expose field do |f,opt|
if f.is_a?(Hash) && f.key?(field)
f[field]
elsif f.is_a?(::Comment)
if f.respond_to?(field)
if field == :created_on
time_from_now(f.send(field))
else
f.send(field)
end
end
end
end
end
comment_expose :id
expose :author, using: Mobile::Entities::User do |c, opt|
if c.is_a? ::Comment
c.author
end
end
comment_expose :comments
comment_expose :created_on
end
end
end

+ 0
- 114
app/api/mobile/entities/course.rb View File

@@ -1,114 +0,0 @@
module Mobile
module Entities
class Course < Grape::Entity
include Redmine::I18n
include ApplicationHelper
include ApiHelper
def self.course_expose(field)
expose field do |f,opt|
c = nil
if f.is_a? ::Course
c = f
else
c = f[:course]
end
if f.is_a?(Hash) && f.key?(field)
f[field] if f.is_a?(Hash) && f.key?(field)
#f.img_url if f.respond_to?(:img_url)
elsif field == :created_at || field == :updated_at
(format_time(c[field]) if (c.is_a?(Hash) && c.key?(field))) || (format_time(c.send(field)) if c.respond_to?(field))
elsif field == :member_count
::Course===c ? c.members.count : 0
else
(c[field] if (c.is_a?(Hash) && c.key?(field))) || (c.send(field) if c.respond_to?(field))
end
end
end
course_expose :img_url
course_expose :attachmenttype
course_expose :class_period
course_expose :code
course_expose :created_at
course_expose :description
course_expose :endup_time
course_expose :extra
course_expose :id
course_expose :inherit_members
course_expose :is_public
course_expose :lft
course_expose :location
course_expose :name
course_expose :open_student
# course_expose :password
course_expose :rgt
course_expose :school_id
course_expose :setup_time
course_expose :state
course_expose :status
course_expose :string
course_expose :tea_id
course_expose :term
course_expose :time
course_expose :invite_code
course_expose :qrcode
course_expose :updated_at
course_expose :course_student_num
course_expose :member_count
course_expose :groupnum
expose :can_setting, if: lambda { |instance, options| options[:user] } do |instance, options|
current_user = options[:user]
can_setting = false

if instance[:course]
course = instance[:course]
else
course = instance
end

member = course.members.where("user_id=#{current_user.id} and course_id=#{course.id}")[0]
role_ids = member.role_ids if member

if role_ids && (role_ids.include?(7) || role_ids.include?(9) )
can_setting = true
end

if course.tea_id == current_user.id
can_setting = true
end
can_setting
end
expose :is_member, if: lambda { |instance, options| options[:user] } do |instance, options|
current_user = options[:user]
if instance[:course]
course = instance[:course]
else
course = instance
end
current_user.member_of_course?(course)
end
expose :teacher, using: Mobile::Entities::User do |c, opt|
if c.is_a? ::Course
c.teacher
else
c[:course].teacher
end
end
expose :my_homework,using: Mobile::Entities::Homework do |f, opt|
f[:my_homework] if f.is_a?(Hash) && f.key?(:my_homework)
end
expose :is_creator, if: lambda { |instance, options| options[:user] } do |instance, options|
if instance[:course]
course = instance[:course]
else
course = instance
end
current_user = options[:user]
course.tea_id == current_user.id
end
course_expose :current_user_is_member
course_expose :current_user_is_teacher
course_expose :work_unit
course_expose :syllabus_title
end
end
end

+ 0
- 90
app/api/mobile/entities/course_dynamic.rb View File

@@ -1,90 +0,0 @@
module Mobile
module Entities
class CourseDynamic < Grape::Entity
include Redmine::I18n
def self.course_dynamic_expose(field)
expose field do |c,opt|
# if field == :news_count
# obj = nil
# c[:dynamics].each do |d|
# if d[:type] == 1
# obj = d[:count]
# end
# end
# obj
# elsif field == :document_count
# obj = nil
# c[:dynamics].each do |d|
# if d[:type] == 3
# obj = d[:count]
# end
# end
# obj
# elsif field == :topic_count
# obj = nil
# c[:dynamics].each do |d|
# if d[:type] == 2
# obj = d[:count]
# end
# end
# obj
# elsif field == :homework_count
# obj = nil
# c[:dynamics].each do |d|
# if d[:type] == 4
# obj = d[:count]
# end
# end
# obj
# else
c[field] if (c.is_a?(Hash) && c.key?(field))
# end
end
end
course_dynamic_expose :course_name
course_dynamic_expose :course_term
course_dynamic_expose :course_time
course_dynamic_expose :course_id
course_dynamic_expose :course_img_url
course_dynamic_expose :message
course_dynamic_expose :news_count
course_dynamic_expose :document_count
course_dynamic_expose :topic_count
course_dynamic_expose :homework_count
course_dynamic_expose :course_student_num
course_dynamic_expose :time_from_now
course_dynamic_expose :current_user_is_member
course_dynamic_expose :current_user_is_teacher
# expose :documents,using:Mobile::Entities::Attachment do |f,opt|
# obj = nil
# f[:dynamics].each do |d|
# if d[:type] == 3
# obj = d[:documents]
# end
# end
# obj
# end
expose :topics,using:Mobile::Entities::Message do |f,opt|
f[:topics]
end
expose :homeworks,using:Mobile::Entities::Homework do |f,opt|
f[:homeworks]
end
expose :news,using:Mobile::Entities::News do |f,opt|
f[:news]
end
expose :better_students,using:Mobile::Entities::User do |f,opt|
f[:better_students]
end
expose :active_students,using:Mobile::Entities::User do |f,opt|
f[:active_students]
end
end
end
end

+ 0
- 19
app/api/mobile/entities/course_group.rb View File

@@ -1,19 +0,0 @@
module Mobile
module Entities
class CourseGroup < Grape::Entity
include Redmine::I18n
include ApplicationHelper
include ApiHelper
def self.course_group_expose(f)
expose f do |u,opt|
if u.is_a?(Hash) && u.key?(f)
u[f]
end
end
end
expose :id
expose :name
expose :users, using: Mobile::Entities::User
end
end
end

+ 0
- 43
app/api/mobile/entities/exercise.rb View File

@@ -1,43 +0,0 @@
module Mobile
module Entities
class Exercise < Grape::Entity
include Redmine::I18n
include ApplicationHelper
include ApiHelper
def self.exercise_expose(field)
expose field do |f,opt|
if f.is_a?(Hash) && f.key?(field)
if field == :created_on
format_time(f[field])
else
f[field]
end
elsif f.is_a?(::Exercise)
if f.respond_to?(field)
f.send(field)
else
case field
when :coursename
f.course.nil? ? "" : f.course.name
when :syllabus_title
f.course.nil? ? "" : f.course.syllabus.nil? ? "" : f.course.syllabus.title
end
end
end
end
end
expose :exercise_name
expose :exercise_description
exercise_expose :coursename #所属班级名
exercise_expose :syllabus_title

expose :current_user_is_teacher, if: lambda { |instance, options| options[:user] } do |instance, options|
current_user = options[:user]
current_user_is_teacher = false
current_user_is_teacher = is_course_teacher(current_user,instance.course)
current_user_is_teacher
end

end
end
end

+ 0
- 115
app/api/mobile/entities/homework.rb View File

@@ -1,115 +0,0 @@
# 这个模块由于作业模块的改变,里边的注释以及属性不可信
module Mobile
module Entities
class Homework < Grape::Entity
include Redmine::I18n
include ApplicationHelper
include ApiHelper
def self.homework_expose(field)
expose field do |f,opt|
if f.is_a?(Hash) && f.key?(field)
if field == :created_on
format_time(f[field])
else
f[field]
end
elsif f.is_a?(::HomeworkCommon)
if f.respond_to?(field)
f.send(field)
else
case field
when :homework_name
f.send(:name)
when :homework_notsubmit_num
f.course.members.count - f.student_works.count
when :homework_submit_num
f.student_works.count
when :homework_status_student
get_homework_status f
when :homework_times
f.course.homework_commons.index(f) + 1
when :homework_status_teacher
homework_status_desc f
when :student_evaluation_part
get_evaluation_part f ,3
when :ta_evaluation_part
get_evaluation_part f , 2
when :homework_anony_type
val = f.homework_type == 1 && !f.homework_detail_manual.nil?
val
when :coursename
f.course.nil? ? "" : f.course.name
when :syllabus_title
f.course.nil? ? "" : f.course.syllabus.nil? ? "" : f.course.syllabus.title
end
end
end
end
end
#作业id
homework_expose :id
#课程名称
homework_expose :course_name
homework_expose :syllabus_title
homework_expose :course_id
#作业发布者
expose :author,using: Mobile::Entities::User do |f, opt|
f[:author]
end
#作业发布者真名
homework_expose :author_real_name
#作业次数
homework_expose :homework_times
#作业名称
homework_expose :homework_name
#已提交的作业数量
homework_expose :homework_count
#学生提问数量
homework_expose :student_questions_count
#作业描述
homework_expose :description
#作业是否启用匿评功能 0:不启用,1启用
homework_expose :open_anonymous_evaluation
#作业状态 0:新建,1:已开启匿评,2:已关闭匿评
#只有作业启用了匿评功能且当前用户是课程老师且已提交的作品数量大于或等于2才能开启匿评
homework_expose :homework_state
homework_expose :created_on
homework_expose :deadline
expose :jours,using: Mobile::Entities::Jours do |f, opt|
f[:jours] if f.is_a?(Hash) && f.key?(:jours)
end
expose :homework_for_anonymous_comments,using: Mobile::Entities::HomeworkAttach do |f, opt|
f[:homework_for_anonymous_comments] if f.is_a?(Hash) && f.key?(:homework_for_anonymous_comments)
end
homework_expose :homework_submit_num
homework_expose :homework_notsubmit_num
homework_expose :homework_status_student #学生看到的作业的状态
homework_expose :homework_status_teacher #老师看到的状态
homework_expose :student_evaluation_part #学生匿评比率
homework_expose :ta_evaluation_part #教辅评价比率
homework_expose :homework_anony_type #是否是匿评作业
homework_expose :coursename #所属班级名
expose :current_user_is_teacher, if: lambda { |instance, options| options[:user] } do |instance, options|
if instance[:current_user_is_teacher].nil?
current_user = options[:user]
current_user_is_teacher = false
current_user_is_teacher = is_course_teacher(current_user,instance.course)
current_user_is_teacher
end
end
end
end
end

+ 0
- 42
app/api/mobile/entities/homework_attach.rb View File

@@ -1,42 +0,0 @@
module Mobile
module Entities
class HomeworkAttach < Grape::Entity
include Redmine::I18n
def self.homework_attach_expose(field)
expose field do |f,opt|
if f.is_a?(Hash) && f.key?(field)
f[field]
elsif f.is_a?(::HomeworkAttach)
if f.respond_to?(field)
if field == :created_at
format_time(f.send(:created_at))
else
f.send(field)
end
else
case field
when :homework_times
f.bid.courses.first.homeworks.index(f.bid) + 1 unless (f.bid.nil? || f.bid.courses.nil? || f.bid.courses.first.nil?)
when :comment_status
f.bid.comment_status
end
end
end
end
end
homework_attach_expose :id
homework_attach_expose :name
homework_attach_expose :homework_times
homework_attach_expose :description
homework_attach_expose :created_at
#comment_status 0:所属作业尚未开启匿评,1:匿评中 2:匿评结束
homework_attach_expose :comment_status
expose :attachments,using: Mobile::Entities::Attachment do |f, opt|
if f.respond_to?(:attachments)
f.send(:attachments)
end
end
end
end
end

+ 0
- 29
app/api/mobile/entities/homework_jours.rb View File

@@ -1,29 +0,0 @@
module Mobile
module Entities
#带评分的留言(教师评论、学生匿名评分都属于此类)
class HomeworkJours < Grape::Entity
include Redmine::I18n
def self.homework_jours_expose(field)
expose field do |f,opt|
if f.is_a?(Hash) && f.key?(field)
if field == :created_at
format_time(f[field])
else
f[field]
end
elsif f.is_a?(::SeemsRateableRates)
end
end
end
homework_jours_expose :rater_id
homework_jours_expose :rater_name
homework_jours_expose :created_at
homework_jours_expose :stars
expose :comment,using: Mobile::Entities::Jours do |f,opt|
f[:comment]
end
end
end
end

+ 0
- 18
app/api/mobile/entities/homeworkscore.rb View File

@@ -1,18 +0,0 @@
module Mobile
module Entities
class Homeworkscore < Grape::Entity
include Redmine::I18n
include ApplicationHelper
def self.homeworkscore_expose(field)
expose field do |f,opt|
if f.is_a?(Hash) && f.key?(field)
f[field]
end
end
end

homeworkscore_expose :name
homeworkscore_expose :score
end
end
end

+ 0
- 187
app/api/mobile/entities/issue.rb View File

@@ -1,187 +0,0 @@
#coding=utf-8
module Mobile
module Entities
class Issue <Grape::Entity
include ApiHelper
include Redmine::I18n
def self.issue_expose(f)
expose f do |issue, opt|
if issue.is_a?(Hash) && issue.key?(f)
issue[f]
elsif issue.is_a?(::Issue)
if issue.respond_to?(f)
if f == :created_on
format_time(issue.send(f))
else
issue.send(f)
end
else
case f
when :issue_priority
get_issue_priority_api issue.priority_id
when :issue_assigned_to
issue.assigned_to_id.nil? ? "未指派" : (get_user(issue.assigned_to_id)).login
when :issue_status
IssueStatus.find(issue.status_id).name
when :comment_count
issue.journals.where("notes is not null and notes != ''").count
# all_comments = []
# get_all_children(all_comments, f).count
when :project_name
issue.project.name
when :praise_count
get_activity_praise_num(issue)
when :act_type
'Issue'
when :act_id
issue.id
when :title
issue.subject
when :subject
issue.subject
when :description
issue.description
when :done_ratio
issue.done_ratio
end
end
elsif issue.is_a?(::Journal)
case f
when :content
issue[:notes]
when :lasted_comment
time_from_now issue.created_on
when :act_id
issue.id
when :act_type
'Journal'
when :praise_count
get_activity_praise_num(issue)
end
end
end
end
issue_expose :subject
issue_expose :description
expose :author, using: Mobile::Entities::User do |f, opt|
if f.is_a?(::Issue)
f.send(:author)
end
end
expose :user,using: Mobile::Entities::User do |f, opt|
if f.is_a?(::Journal)
f.send(:user)
end
end
issue_expose :content
issue_expose :lasted_comment
issue_expose :done_ratio
issue_expose :title
issue_expose :act_type
issue_expose :act_id
issue_expose :created_on
issue_expose :issue_priority
issue_expose :issue_assigned_to
issue_expose :issue_status
issue_expose :comment_count
issue_expose :project_name
issue_expose :praise_count
expose :id
# expose :issue_journals, using: Mobile::Entities::Journal do |f, opt|
# if f.is_a?(::Issue)
# f.journals.where("notes is not null and notes != ''").reverse
# end
# end
expose :all_children, using: Mobile::Entities::Issue do |f, opt|
#f[:journals_for_messages] if f.is_a?(Hash) && f.key?(:journals_for_messages)
if f.is_a?(::Issue)
# f.journals_for_messages.reverse
if !opt[:children] && opt[:type] == 0
opt[:children] = true
tStart = opt[:page]*5
tEnd = (opt[:page]+1)*5 - 1
all_comments = f.journals.where("notes is not null and notes != ''").reorder("created_on desc")
all_comments[tStart..tEnd]
end
end
end
expose :has_praise , if: lambda { |instance, options| options[:user] } do |instance, options|
has_praise = false
current_user = options[:user]
obj = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",instance.id,instance.class.to_s,current_user.id)
has_praise = obj.empty? ? false : true
has_praise
end
expose :parents_count, if: lambda { |instance, options| options[:user] } do |instance, options|
if instance.is_a?(::Journal)
parents_reply = []
parents_reply = get_reply_parents(parents_reply, instance)
parents_reply.count
end
end
expose :parents_reply_bottom, using:Mobile::Entities::Issue do |f,opt|
if f.is_a? (::Journal)
#取二级回复的底楼层
parents_reply = []
parents_reply = get_reply_parents(parents_reply, f)
if parents_reply.count > 0 && !opt[:bottom]
if opt[:type] == 1
# opt[:bottom] = true
# parents_reply[opt[:page]..opt[:page]]
else
opt[:bottom] = true
parents_reply[0..0]
end
else
[]
end
end
end
expose :parents_reply_top, using:Mobile::Entities::Issue do |f,opt|
if f.is_a? (::Journal)
#取二级回复的顶楼层
parents_reply = []
parents_reply = get_reply_parents(parents_reply, f)
if parents_reply.count > 2 && !opt[:top]
if opt[:type] == 1
opt[:top] = true
tStart = (opt[:page]-1)*5+2
tEnd = (opt[:page])*5+2 - 1
if tEnd >= parents_reply.count - 1
tEnd = parents_reply.count - 2
end
if tStart <= parents_reply.count - 2
parents_reply = parents_reply.reverse[tStart..tEnd]
parents_reply.reverse
else
[]
end
else
opt[:top] = true
parents_reply = parents_reply.reverse[0..1]
parents_reply.reverse
end
elsif parents_reply.count == 2 && !opt[:top]
opt[:top] = true
parents_reply = parents_reply.reverse[0..0]
parents_reply.reverse
else
[]
end
end
end
expose :attachments, using: Mobile::Entities::Attachment
end
end
end

+ 0
- 44
app/api/mobile/entities/journal.rb View File

@@ -1,44 +0,0 @@
module Mobile
module Entities
class Journal <Grape::Entity
include Redmine::I18n
=begin
include Redmine::I18n
include ApplicationHelper
include ApiHelper
include IssuesHelper
include ActionView::Helpers::TagHelper
include ActionView::Helpers::UrlHelper
=end
def self.journal_expose(f)
expose f do |journal, opt|
if journal.is_a?(Hash) && journal.key?(f)
journal[f]
elsif journal.is_a?(::Journal)
if journal.respond_to?(f)
if f == :created_on
time_from_now(journal.send(f))
else
journal.send(f)
end
else
case f
when :detail_journal
if journal.details.any?
details_to_strings(journal.details)
end
end
end
end
end
end

expose :notes
journal_expose :created_on
expose :user,using: Mobile::Entities::User do |f, opt|
f.user
end
#journal_expose :detail_journal
end
end
end

+ 0
- 161
app/api/mobile/entities/jours.rb View File

@@ -1,161 +0,0 @@
module Mobile
module Entities
#普通留言
class Jours < Grape::Entity
include Redmine::I18n
def self.jours_expose(field)
expose field do |f,opt|
if f.is_a?(Hash) && f.key?(field)
f[field]
elsif f.is_a?(::JournalsForMessage) && f.respond_to?(field)
if field == :created_on
format_time(f.send(field))
else
f.send(field)
end
else
case field
when :lasted_comment
time_from_now f.created_on
when :comment_count
# f.children.count
all_comments = []
get_all_children(all_comments, f).count
when :praise_count
get_activity_praise_num(f)
when :act_type
'JournalsForMessage'
when :act_id
f.id
when :content
f.notes
end
end
end
end
jours_expose :act_type
jours_expose :act_id
jours_expose :id
jours_expose :jour_type
jours_expose :jour_id
expose :user,using: Mobile::Entities::User do |f, opt|
f.user
end
jours_expose :created_on
jours_expose :lasted_comment
jours_expose :content
jours_expose :m_reply_id
jours_expose :m_parent_id
jours_expose :comment_count
jours_expose :praise_count
expose :course,using:Mobile::Entities::Course do |f,opt|
if f.is_a?(::JournalsForMessage) && f[:jour_type] == "Course"
f.course
end
end
expose :reply_user,using: Mobile::Entities::User do |f, opt|
f.at_user
end
expose :all_children,using: Mobile::Entities::Jours do |f, opt|
if f.is_a?(::JournalsForMessage)
# f.children.reverse
if !opt[:children] && opt[:comment_type].nil?
if f.parent.nil? && opt[:type] == 0
opt[:children] = true
all_comments = []
tStart = opt[:page]*5
tEnd = (opt[:page]+1)*5 - 1
all_comments = get_all_children(all_comments, f)[tStart..tEnd]
all_comments
end
end
end
end
expose :has_praise , if: lambda { |instance, options| options[:user] } do |instance, options|
has_praise = false
current_user = options[:user]
obj = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",instance.id,instance.class.to_s,current_user.id)
has_praise = obj.empty? ? false : true
has_praise
end
expose :parents_count, if: lambda { |instance, options| options[:user] } do |instance, options|
parents_reply = []
if options[:comment_type].nil?
parents_reply = get_reply_parents_no_root(parents_reply, instance)
elsif options[:comment_type] == "homework"
parents_reply = get_reply_parents(parents_reply, instance)
end
parents_reply.count
end
expose :parents_reply_bottom, using:Mobile::Entities::Jours do |f,opt|
if f.is_a? (::JournalsForMessage)
#取二级回复的底楼层
parents_reply = []
if opt[:comment_type].nil?
parents_reply = get_reply_parents_no_root(parents_reply, f)
elsif opt[:comment_type] == "homework"
parents_reply = get_reply_parents(parents_reply, f)
end
if parents_reply.count > 0 && !opt[:bottom]
if opt[:type] == 1
# opt[:bottom] = true
# parents_reply[opt[:page]..opt[:page]]
else
opt[:bottom] = true
parents_reply[0..0]
end
else
[]
end
end
end
expose :parents_reply_top, using:Mobile::Entities::Jours do |f,opt|
if f.is_a? (::JournalsForMessage)
#取二级回复的顶楼层
parents_reply = []
if opt[:comment_type].nil?
parents_reply = get_reply_parents_no_root(parents_reply, f)
elsif opt[:comment_type] == "homework"
parents_reply = get_reply_parents(parents_reply, f)
end
if parents_reply.count > 2 && !opt[:top]
if opt[:type] == 1
opt[:top] = true
tStart = (opt[:page]-1)*5+2
tEnd = (opt[:page])*5+2 - 1
if tEnd >= parents_reply.count - 1
tEnd = parents_reply.count - 2
end
if tStart <= parents_reply.count - 2
parents_reply = parents_reply.reverse[tStart..tEnd]
parents_reply.reverse
else
[]
end
else
opt[:top] = true
parents_reply = parents_reply.reverse[0..1]
parents_reply.reverse
end
elsif parents_reply.count == 2 && !opt[:top]
opt[:top] = true
parents_reply = parents_reply.reverse[0..0]
parents_reply.reverse
else
[]
end
end
end
end
end
end

+ 0
- 34
app/api/mobile/entities/member.rb View File

@@ -1,34 +0,0 @@
module Mobile
module Entities
class Member < Grape::Entity
include ApplicationHelper
include ApiHelper
def self.member_expose(f)
expose f do |u,opt|
if u.is_a?(Hash) && u.key?(f)
u[f]
elsif u.is_a?(::Member)
if u.respond_to?(f)
u.send(f)
else
case f
when :student_id
u.user.user_extensions.student_id
end
end
end

end
end

expose :user, using: Mobile::Entities::User do |c, opt|
if c.is_a?(::Member)
c.user
end
end
member_expose :student_id
member_expose :score
member_expose :id
end
end
end

+ 0
- 154
app/api/mobile/entities/message.rb View File

@@ -1,154 +0,0 @@
module Mobile
module Entities
class Message < Grape::Entity
include ApplicationHelper
include ApiHelper
def self.message_expose(f)
expose f do |u,opt|
if u.is_a?(Hash) && u.key?(f)
u[f]
elsif u.is_a?(::Message)
if u.respond_to?(f)
if f == :created_on
format_time( u.send(f))
else
u.send(f)
end
else
case f
when :course_project_name
if u.board.project_id == -1
u.course.name
else
u.project.name
end
when :syllabus_title
if u.board.project_id == -1
u.course.syllabus.nil? ? "" : u.course.syllabus.title
end
when :lasted_comment
time_from_now u.created_on
when :praise_count
get_activity_praise_num(u)
when :act_type
'Message'
when :act_id
u.id
when :comment_count
all_comments = []
get_all_children(all_comments, u).count
when :title
u.subject
end
end
end

end
end

expose :user, using: Mobile::Entities::User do |c, opt|
if c.is_a?(::Message)
c.author
end
end
message_expose :act_type
message_expose :act_id
message_expose :course_project_name
message_expose :syllabus_title
message_expose :board_id
message_expose :subject
message_expose :title
message_expose :content
message_expose :comment_count
message_expose :praise_count
message_expose :created_on
message_expose :locked
message_expose :id
message_expose :lasted_comment
expose :all_children,using:Mobile::Entities::Message do |c,opt|
if c.is_a? (::Message)
# c.children.reverse
if !opt[:children]
if c.parent.nil? && opt[:type] == 0
opt[:children] = true
all_comments = []
tStart = opt[:page]*5
tEnd = (opt[:page]+1)*5 - 1

all_comments = get_all_children(all_comments, c)[tStart..tEnd]
all_comments
end
end
end
end
expose :has_praise , if: lambda { |instance, options| options[:user] } do |instance, options|
has_praise = false
current_user = options[:user]
obj = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",instance.id,instance.class.to_s,current_user.id)
has_praise = obj.empty? ? false : true
has_praise
end

expose :parents_count, if: lambda { |instance, options| options[:user] } do |instance, options|
parents_reply = []
parents_reply = get_reply_parents_no_root(parents_reply, instance)
parents_reply.count
end

expose :parents_reply_bottom, using:Mobile::Entities::Message do |c,opt|
if c.is_a? (::Message)
#取二级回复的底楼层
parents_reply = []
parents_reply = get_reply_parents_no_root(parents_reply, c)
if parents_reply.count > 0 && !opt[:bottom]
if opt[:type] == 1
# opt[:bottom] = true
# parents_reply[opt[:page]..opt[:page]]
else
opt[:bottom] = true
parents_reply[0..0]
end
else
[]
end
end
end

expose :parents_reply_top, using:Mobile::Entities::Message do |c,opt|
if c.is_a? (::Message)
#取二级回复的顶楼层
parents_reply = []
parents_reply = get_reply_parents_no_root(parents_reply, c)
if parents_reply.count > 2 && !opt[:top]
if opt[:type] == 1
opt[:top] = true
tStart = (opt[:page]-1)*5+2
tEnd = (opt[:page])*5+2 - 1

if tEnd >= parents_reply.count - 1
tEnd = parents_reply.count - 2
end

if tStart <= parents_reply.count - 2
parents_reply = parents_reply.reverse[tStart..tEnd]
parents_reply.reverse
else
[]
end
else
opt[:top] = true
parents_reply = parents_reply.reverse[0..1]
parents_reply.reverse
end
elsif parents_reply.count == 2 && !opt[:top]
opt[:top] = true
parents_reply = parents_reply.reverse[0..0]
parents_reply.reverse
else
[]
end
end
end
end
end
end

+ 0
- 198
app/api/mobile/entities/news.rb View File

@@ -1,198 +0,0 @@
module Mobile
module Entities
class News < Grape::Entity
include Redmine::I18n
include ApiHelper
def self.news_expose(field)
expose field do |f,opt|
if f.is_a?(Hash) && f.key?(field)
f[field]
elsif f.is_a?(::News)
if f.respond_to?(field)
if field == :created_on
format_time(f.send(field))
else
f.send(field)
end
else
case field
when :course_name
get_course(f.course_id).name unless f.course_id == nil
when :praise_count
get_activity_praise_num(f)
when :act_type
'News'
when :act_id
f.id
when :comment_count
f.comments.count
when :syllabus_title
unless f.course_id == nil
course = get_course(f.course_id)
course.syllabus.nil? ? "" : course.syllabus.title
end
end
end
elsif f.is_a?(::Comment)
case field
when :content
f[:comments]
when :lasted_comment
time_from_now f.created_on
when :act_id
f.id
when :praise_count
get_activity_praise_num(f)
when :act_type
'Comment'
end
elsif f.is_a?(Hash) && !f.key?(field)
n = f[:news]
comments = f[:comments]
if n.is_a?(::News)
if field == :created_on
format_time(n.send(field)) if n.respond_to?(field)
else
n.send(field) if n.respond_to?(field)
end
end
end
end
end
expose :id
#新闻标题
news_expose :title
expose :user,using: Mobile::Entities::User do |f, opt|
obj = nil
if f.is_a?(::News) && f.respond_to?(:author)
obj = f.send(:author)
elsif f.is_a?(::Comment) && f.respond_to?(:author)
obj = f.send(:author)
elsif f.is_a?(Hash) && f.key?(:author)
obj = f[:author]
end
obj
end
news_expose :act_type
news_expose :act_id
#作者id
news_expose :author_id
#作者名
news_expose :author_name
#作者头像url
news_expose :author_img_url
#新闻内容
news_expose :description
#发布时间
news_expose :created_on
#评论数量
news_expose :comment_count
news_expose :praise_count
#课程名字
news_expose :course_name
news_expose :syllabus_title
news_expose :lasted_comment
#评论
# expose :comments, using: Mobile::Entities::Comment do |f, opt|
# if f.is_a?(Hash) && f.key?(:comments)
# f[:comments]
# elsif f.is_a?(::News) && f.respond_to?(:comments)
# f.comments.reverse
# end
# end
news_expose :content
expose :all_children, using: Mobile::Entities::News do |f, opt|
#f[:journals_for_messages] if f.is_a?(Hash) && f.key?(:journals_for_messages)
if f.is_a?(::News)
# f.journals_for_messages.reverse
if !opt[:children] && opt[:type] == 0
opt[:children] = true
tStart = opt[:page]*5
tEnd = (opt[:page]+1)*5 - 1
all_comments = f.comments.reorder("created_on desc")
all_comments[tStart..tEnd]
end
end
end
expose :has_praise , if: lambda { |instance, options| options[:user] } do |instance, options|
has_praise = false
current_user = options[:user]
obj = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",instance.id,instance.class.to_s,current_user.id)
has_praise = obj.empty? ? false : true
has_praise
end
expose :parents_count, if: lambda { |instance, options| options[:user] } do |instance, options|
if instance.is_a?(::Comment)
parents_reply = []
parents_reply = get_reply_parents(parents_reply, instance)
parents_reply.count
end
end
expose :parents_reply_bottom, using:Mobile::Entities::News do |f,opt|
if f.is_a? (::Comment)
#取二级回复的底楼层
parents_reply = []
parents_reply = get_reply_parents(parents_reply, f)
if parents_reply.count > 0 && !opt[:bottom]
if opt[:type] == 1
# opt[:bottom] = true
# parents_reply[opt[:page]..opt[:page]]
else
opt[:bottom] = true
parents_reply[0..0]
end
else
[]
end
end
end
expose :parents_reply_top, using:Mobile::Entities::News do |f,opt|
if f.is_a? (::Comment)
#取二级回复的顶楼层
parents_reply = []
parents_reply = get_reply_parents(parents_reply, f)
if parents_reply.count > 2 && !opt[:top]
if opt[:type] == 1
opt[:top] = true
tStart = (opt[:page]-1)*5+2
tEnd = (opt[:page])*5+2 - 1
if tEnd >= parents_reply.count - 1
tEnd = parents_reply.count - 2
end
if tStart <= parents_reply.count - 2
parents_reply = parents_reply.reverse[tStart..tEnd]
parents_reply.reverse
else
[]
end
else
opt[:top] = true
parents_reply = parents_reply.reverse[0..1]
parents_reply.reverse
end
elsif parents_reply.count == 2 && !opt[:top]
opt[:top] = true
parents_reply = parents_reply.reverse[0..0]
parents_reply.reverse
else
[]
end
end
end
end
end
end

+ 0
- 43
app/api/mobile/entities/project.rb View File

@@ -1,43 +0,0 @@
module Mobile
module Entities
class Project < Grape::Entity
expose :name
expose :id
expose :is_public
expose :user_id
expose :invite_code
expose :qrcode
expose :can_setting, if: lambda { |instance, options| options[:user] } do |instance, options|
current_user = options[:user]

my_member = instance.member_principals.where("users.id=#{current_user.id}").first
can_setting = false
if my_member && my_member.roles[0] && my_member.roles[0].id == 3
can_setting = true
end
can_setting
end

expose :is_creator, if: lambda { |instance, options| options[:user] } do |instance, options|
current_user = options[:user]

current_user.id == instance.user_id
end

expose :is_member, if: lambda { |instance, options| options[:user] } do |instance, options|
current_user = options[:user]
if instance[:project]
project = instance[:project]
else
project = instance
end
current_user.member_of?(project)
end


expose :member_count, if: lambda { |instance, options| options[:user] } do |instance, options|
instance.members.count
end
end
end
end

+ 0
- 35
app/api/mobile/entities/project_member.rb View File

@@ -1,35 +0,0 @@
module Mobile
module Entities
class ProjectMember < Grape::Entity
include Redmine::I18n
include ApplicationHelper
include ApiHelper
def self.member_expose(f)
expose f do |u,opt|
if u.is_a?(Hash) && u.key?(f)
u[f]
elsif u.is_a?(::Member)
if u.respond_to?(f)
u.send(f)
else
case f
when :roles_id
# u.roles[0].id
u.roles.map {|r| r.id}
end
end
end
end
end

expose :user, using: Mobile::Entities::User do |c, opt|
if c.is_a?(::Member)
c.user
end
end

member_expose :roles_id

end
end
end

+ 0
- 45
app/api/mobile/entities/student_work.rb View File

@@ -1,45 +0,0 @@
module Mobile
module Entities
class StudentWork < Grape::Entity
include ApplicationHelper
include ApiHelper
def self.student_work_expose(f)
expose f do |u,opt|
if u.is_a?(Hash) && u.key?(f)
u[f]
elsif u.is_a?(::StudentWork)
if u.respond_to?(f)
if f == :created_at
format_time(u.send(:created_at))
else
u.send(f)
end

else
case f
when :student_id
u.user.user_extensions.student_id
end
end
end

end
end

expose :user, using: Mobile::Entities::User do |c, opt|
if c.is_a?(::StudentWork)
c.user
end
end
student_work_expose :student_id
student_work_expose :id
student_work_expose :name
student_work_expose :description
student_work_expose :final_score
student_work_expose :teacher_score
student_work_expose :student_score
student_work_expose :teacher_asistant_score
student_work_expose :created_at
end
end
end

+ 0
- 15
app/api/mobile/entities/syllabus.rb View File

@@ -1,15 +0,0 @@
module Mobile
module Entities
class Syllabus < Grape::Entity
expose :title
expose :id
expose :can_setting, if: lambda { |instance, options| options[:user] } do |instance, options|
current_user = options[:user]
can_setting = instance[:user_id] == current_user.id ? true : false
can_setting = false if instance[:id].nil?
can_setting
end
expose :courses, using: Mobile::Entities::Course
end
end
end

+ 0
- 87
app/api/mobile/entities/user.rb View File

@@ -1,87 +0,0 @@
module Mobile
module Entities
class User < Grape::Entity
include ApplicationHelper
include ApiHelper
def self.user_expose(f)
expose f do |u,opt|
if u.is_a?(Hash) && u.key?(f)
u[f]
elsif u.is_a?(::User)
if u.respond_to?(f)
u.send(f) unless u.user_extensions.nil?
else
case f
when :img_url
"/images/#{url_to_avatar(u)}"
when :gender
u.nil? || u.user_extensions.nil? || u.user_extensions.gender.nil? ? 0 : u.user_extensions.gender
when :work_unit
get_user_work_unit u unless u.user_extensions.nil?
when :location
get_user_location u unless u.user_extensions.nil?
when :brief_introduction
u.nil? || u.user_extensions.nil? ? "" : u.user_extensions.brief_introduction
when :student_num
u.nil? || u.user_extensions.nil? ? "" : u.user_extensions.student_id
when :real_name
u.nil? ? "" : get_user_realname(u).gsub(/\s*/,"");
when :name
u.nil? ? "" : u.show_name
when :roles_id
u[:roles_id].nil? ? nil : u.roles_id
when :login
u.login
when :lastname
u.lastname
when :mail
u.mail
when :is_me
defined? u.is_me ? u.is_me : 0
end
end
end
end
end

expose :id
#头像
user_expose :login
user_expose :lastname
#邮箱地址
user_expose :mail
expose :nickname
#真名
user_expose :img_url
#昵称
expose :realname
#昵称
user_expose :real_name
#性别
user_expose :gender
#我的二维码
#工作单位
user_expose :work_unit
#地区
user_expose :location
#签名
user_expose :brief_introduction
#总成绩
user_expose :score
#学号
user_expose :student_num
# 活跃值
user_expose :active_count

user_expose :role_name

user_expose :roles_id

user_expose :name

user_expose :is_me

end
end

end

+ 0
- 119
app/api/mobile/entities/whomework.rb View File

@@ -1,119 +0,0 @@
# encoding: utf-8
module Mobile
module Entities
class Whomework <Grape::Entity
include ApiHelper
include ApplicationHelper
include Redmine::I18n
def self.whomework_expose(f)
expose f do |wh, opt|
if wh.is_a?(Hash) && wh.key?(f)
wh[f]
elsif wh.is_a?(::HomeworkCommon)
if wh.respond_to?(f)
if f == :created_at
format_time(wh.send(f))
else
wh.send(f)
end
else
case f
when :absence_penalty
wh.nil? || wh.homework_detail_manual.nil? ? 0 : wh.homework_detail_manual.absence_penalty
when :evaluation_start
wh.nil? || wh.homework_detail_manual.nil? ? nil : convert_to_time(wh.homework_detail_manual.evaluation_start, 0)
when :evaluation_end
wh.nil? || wh.homework_detail_manual.nil? ? nil : convert_to_time(wh.homework_detail_manual.evaluation_end, 1)
when :praise_count
get_activity_praise_num(wh)
when :comment_count
wh.journals_for_messages.count
when :course_name
wh.course.name
when :syllabus_title
wh.course.syllabus.nil? ? "" : wh.course.syllabus.title
when :act_type
'HomeworkCommon'
when :act_id
wh.id
when :title
wh.name
when :homework_commit_count
wh.student_works.has_committed.count
when :last_commit_info
if wh.student_works.has_committed.count > 0
lc = wh.student_works.has_committed.reorder("commit_time desc").first
{:lasttime=>time_from_now(lc.commit_time), :lastname=>lc.user.show_name}
end
when :last_score_info
if wh.student_works.has_committed.count > 0
sw_id = "("+wh.student_works.map{|sw| sw.id}.join(",")+")"
student_work_scores = StudentWorksScore.where("student_work_id in #{sw_id} and score is not null").reorder("created_at desc")
unless student_work_scores.empty?
last_score = student_work_scores.first
{:lasttime=>time_from_now(last_score.created_at), :lastname=>last_score.user.show_name}
end
end
end
end
end
end
end

expose :author, using: Mobile::Entities::User do |w, opt|
if w.is_a?(::HomeworkCommon)
w.user
end
end
expose :current_user, using: Mobile::Entities::User do |w, opt|
current_user
end
expose :name
expose :description
expose :publish_time
expose :end_time
expose :homework_type
expose :late_penalty
expose :course_id
expose :anonymous_comment
expose :quotes
expose :is_open
expose :id
whomework_expose :title
whomework_expose :act_type
whomework_expose :act_id
whomework_expose :course_name
whomework_expose :syllabus_title
whomework_expose :created_at
whomework_expose :absence_penalty
whomework_expose :evaluation_start
whomework_expose :evaluation_end
whomework_expose :praise_count
whomework_expose :comment_count
whomework_expose :homework_commit_count #作品提交数
whomework_expose :last_commit_info #最近提交信息
whomework_expose :last_score_info #最近评阅信息
expose :all_children, using: Mobile::Entities::Jours do |f, opt|
#f[:journals_for_messages] if f.is_a?(Hash) && f.key?(:journals_for_messages)
if f.is_a?(::HomeworkCommon)
# f.journals_for_messages.reverse
if !opt[:children] && opt[:type] == 0
opt[:children] = true
tStart = opt[:page]*5
tEnd = (opt[:page]+1)*5 - 1

all_comments = f.journals_for_messages.reorder("created_on desc")
all_comments[tStart..tEnd]
end
end
end
expose :has_praise , if: lambda { |instance, options| options[:user] } do |instance, options|
has_praise = false
current_user = options[:user]
obj = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",instance.id,instance.class.to_s,current_user.id)
has_praise = obj.empty? ? false : true
has_praise
end
end
end
end

+ 0
- 13
app/api/mobile/exceptions/auth_exception.rb View File

@@ -1,13 +0,0 @@
#coding=utf-8
#
module Mobile
module Exceptions
class AuthException < StandardError
attr_reader :err_code, :msg
def initialize(code, msg)
@err_code = code
@msg = msg
end
end
end
end

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save