Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
a07923a5
Commit
a07923a5
authored
Oct 21, 2011
by
gitlabhq
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
recent radio button
parent
b5a5e5a4
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
55 additions
and
22 deletions
+55
-22
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+16
-18
app/models/note.rb
app/models/note.rb
+1
-0
app/models/project.rb
app/models/project.rb
+28
-0
app/views/projects/show.html.haml
app/views/projects/show.html.haml
+5
-2
app/views/projects/wall.html.haml
app/views/projects/wall.html.haml
+4
-1
spec/requests/projects_spec.rb
spec/requests/projects_spec.rb
+1
-1
No files found.
app/controllers/projects_controller.rb
View file @
a07923a5
...
@@ -60,24 +60,21 @@ class ProjectsController < ApplicationController
...
@@ -60,24 +60,21 @@ class ProjectsController < ApplicationController
end
end
def
show
def
show
if
@project
.
repo_exists?
return
render
"projects/empty"
unless
@project
.
repo_exists?
@date
=
case
params
[
:view
]
@date
=
case
params
[
:view
]
when
"week"
then
Date
.
today
-
7
.
days
when
"week"
then
Date
.
today
-
7
.
days
else
Date
.
today
when
"day"
then
Date
.
today
end
.
at_beginning_of_day
else
nil
end
@heads
=
@project
.
repo
.
heads
@commits
=
@heads
.
map
do
|
h
|
if
@date
@project
.
repo
.
log
(
h
.
name
,
nil
,
:since
=>
@date
)
@date
=
@date
.
at_beginning_of_day
end
.
flatten
.
uniq
{
|
c
|
c
.
id
}
@commits
.
sort!
do
|
x
,
y
|
y
.
committed_date
<=>
x
.
committed_date
end
@commits
=
@project
.
commits_since
(
@date
)
@messages
=
project
.
notes
.
since
(
@date
).
order
(
"created_at DESC"
)
@messages
=
project
.
notes
.
since
(
@date
).
order
(
"created_at DESC"
)
else
else
return
render
"projects/empty"
@commits
=
@project
.
fresh_commits
@messages
=
project
.
notes
.
fresh
.
limit
(
10
)
end
end
end
end
...
@@ -89,11 +86,12 @@ class ProjectsController < ApplicationController
...
@@ -89,11 +86,12 @@ class ProjectsController < ApplicationController
@date
=
case
params
[
:view
]
@date
=
case
params
[
:view
]
when
"week"
then
Date
.
today
-
7
.
days
when
"week"
then
Date
.
today
-
7
.
days
when
"all"
then
nil
when
"all"
then
nil
else
Date
.
today
when
"day"
then
Date
.
today
else
nil
end
end
@notes
=
@project
.
common_notes
.
order
(
"created_at DESC"
)
@notes
=
@project
.
common_notes
.
order
(
"created_at DESC"
)
@notes
=
@
notes
.
since
(
@date
.
at_beginning_of_day
)
if
@date
@notes
=
@
date
?
@notes
.
since
(
@date
.
at_beginning_of_day
)
:
@notes
.
fresh
.
limit
(
10
)
@note
=
Note
.
new
@note
=
Note
.
new
end
end
...
...
app/models/note.rb
View file @
a07923a5
...
@@ -24,6 +24,7 @@ class Note < ActiveRecord::Base
...
@@ -24,6 +24,7 @@ class Note < ActiveRecord::Base
scope
:last_week
,
where
(
"created_at >= :date"
,
:date
=>
(
Date
.
today
-
7
.
days
))
scope
:last_week
,
where
(
"created_at >= :date"
,
:date
=>
(
Date
.
today
-
7
.
days
))
scope
:since
,
lambda
{
|
day
|
where
(
"created_at >= :date"
,
:date
=>
(
day
))
}
scope
:since
,
lambda
{
|
day
|
where
(
"created_at >= :date"
,
:date
=>
(
day
))
}
scope
:fresh
,
order
(
"created_at DESC"
)
mount_uploader
:attachment
,
AttachmentUploader
mount_uploader
:attachment
,
AttachmentUploader
end
end
...
...
app/models/project.rb
View file @
a07923a5
...
@@ -126,6 +126,34 @@ class Project < ActiveRecord::Base
...
@@ -126,6 +126,34 @@ class Project < ActiveRecord::Base
end
end
end
end
def
heads
@heads
||=
repo
.
heads
end
def
fresh_commits
commits
=
heads
.
map
do
|
h
|
repo
.
commits
(
h
.
name
,
10
)
end
.
flatten
.
uniq
{
|
c
|
c
.
id
}
commits
.
sort!
do
|
x
,
y
|
y
.
committed_date
<=>
x
.
committed_date
end
commits
[
0
..
10
]
end
def
commits_since
(
date
)
commits
=
heads
.
map
do
|
h
|
repo
.
log
(
h
.
name
,
nil
,
:since
=>
date
)
end
.
flatten
.
uniq
{
|
c
|
c
.
id
}
commits
.
sort!
do
|
x
,
y
|
y
.
committed_date
<=>
x
.
committed_date
end
commits
end
def
tree
(
fcommit
,
path
=
nil
)
def
tree
(
fcommit
,
path
=
nil
)
fcommit
=
commit
if
fcommit
==
:head
fcommit
=
commit
if
fcommit
==
:head
tree
=
fcommit
.
tree
tree
=
fcommit
.
tree
...
...
app/views/projects/show.html.haml
View file @
a07923a5
%div
%div
%h2
.left
Recent h
istory
%h2
.left
H
istory
.right
.right
=
form_tag
project_path
(
@project
),
:method
=>
:get
do
=
form_tag
project_path
(
@project
),
:method
=>
:get
do
.span-2
.span-2
=
radio_button_tag
:view
,
"day"
,
(
params
[
:view
]
||
"day"
)
==
"day"
,
:onclick
=>
"this.form.submit()"
,
:id
=>
"day_view"
=
radio_button_tag
:view
,
"recent"
,
(
params
[
:view
]
||
"recent"
)
==
"recent"
,
:onclick
=>
"this.form.submit()"
,
:id
=>
"recent_view"
=
label_tag
"recent_view"
,
"Recent"
.span-2
=
radio_button_tag
:view
,
"day"
,
params
[
:view
]
==
"day"
,
:onclick
=>
"this.form.submit()"
,
:id
=>
"day_view"
=
label_tag
"day_view"
,
"Today"
=
label_tag
"day_view"
,
"Today"
.span-2
.span-2
=
radio_button_tag
:view
,
"week"
,
params
[
:view
]
==
"week"
,
:onclick
=>
"this.form.submit()"
,
:id
=>
"week_view"
=
radio_button_tag
:view
,
"week"
,
params
[
:view
]
==
"week"
,
:onclick
=>
"this.form.submit()"
,
:id
=>
"week_view"
...
...
app/views/projects/wall.html.haml
View file @
a07923a5
...
@@ -4,7 +4,10 @@
...
@@ -4,7 +4,10 @@
.right
.right
=
form_tag
wall_project_path
(
@project
),
:method
=>
:get
do
=
form_tag
wall_project_path
(
@project
),
:method
=>
:get
do
.span-2
.span-2
=
radio_button_tag
:view
,
"day"
,
(
params
[
:view
]
||
"day"
)
==
"day"
,
:onclick
=>
"this.form.submit()"
,
:id
=>
"day_view"
=
radio_button_tag
:view
,
"recent"
,
(
params
[
:view
]
||
"recent"
)
==
"recent"
,
:onclick
=>
"this.form.submit()"
,
:id
=>
"recent_view"
=
label_tag
"recent_view"
,
"Recent"
.span-2
=
radio_button_tag
:view
,
"day"
,
params
[
:view
]
==
"day"
,
:onclick
=>
"this.form.submit()"
,
:id
=>
"day_view"
=
label_tag
"day_view"
,
"Today"
=
label_tag
"day_view"
,
"Today"
.span-2
.span-2
=
radio_button_tag
:view
,
"week"
,
params
[
:view
]
==
"week"
,
:onclick
=>
"this.form.submit()"
,
:id
=>
"week_view"
=
radio_button_tag
:view
,
"week"
,
params
[
:view
]
==
"week"
,
:onclick
=>
"this.form.submit()"
,
:id
=>
"week_view"
...
...
spec/requests/projects_spec.rb
View file @
a07923a5
...
@@ -73,7 +73,7 @@ describe "Projects" do
...
@@ -73,7 +73,7 @@ describe "Projects" do
end
end
it
"should beahave like dashboard"
do
it
"should beahave like dashboard"
do
page
.
should
have_content
(
"
Recent h
istory"
)
page
.
should
have_content
(
"
H
istory"
)
end
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment