aboutsummaryrefslogtreecommitdiffstats
path: root/app/views/user/show.rhtml
blob: 4e895f2e2bf70203ad756627c2613d8157c9a159 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<% @title = h(@display_user.name) + (@is_you ? " (you)" : "") %>

<% if (@same_name_users.size >= 1) %>
    <p>There is <strong>more than one person</strong> who uses this site and has this name. 
    One of them is shown below, you may mean a different one: <% for @same_name_user in @same_name_users %>
        <%= user_link(@same_name_user) %>
    <% end %> 
<% end%>

<% if @is_you && @undescribed_requests.size > 0 %>
    <div class="undescribed_requests">
        <p>Please <strong>go to the following requests</strong>, and let us
        know if there was information in the recent responses to them.</p>
        <ul>
        <% for undescribed_request in @undescribed_requests %>
            <li><%=request_link(undescribed_request)%></li>
        <% end %>
        </ul>
        <p>
            Thanks very much - this will help others find useful stuff. We'll
            also, if you need it, give advice on what to do next about your
            requests.
        </p>
    </div>
<% end %>


<div id="request_sidebar">
    <h2>Track this person</h2>
    <%= render :partial => 'track/tracking_links', :locals => { :track_thing => @track_thing, :own_request => false, :location => 'sidebar' } %>
</div> 

<div class="single_user">
    <h1><%=@title%></h1>
    <p class="subtitle">
        Joined WhatDoTheyKnow in <%= year_from_date(@display_user.created_at) %>
        <% if !@user.nil? && @user.admin_page_links? %>
        (<%= link_to "admin", user_admin_url(@display_user) %>)
        <% end %>
    </p>

    <p>
        <%= link_to "Send message to " + h(@display_user.name), contact_user_url(:id => @display_user.id) %>
        <% if @is_you %>
            (just to see how it works)
            <br><%= link_to "Change your password", signchange_url() %>
        <% end %>
    </p>

    <% if not @is_you %>
        <p>
            If you are <%=h @display_user.name %>, <%= link_to "sign in", signin_url(:r => request.request_uri) %> to change your password or alter your subscriptions.
        </p>
    <% end %>

    <% if !@xapian_requests.nil? %>
        <% if @xapian_requests.results.empty? %>
            <% if @page == 1 %>
                <h2>Freedom of Information requests made by <%= @is_you ? 'you' : 'this person' %> </h2>
                <p><%= @is_you ? 'You have' : 'This person has' %>
                made no Freedom of Information requests using this site.</p>
            <% end %>
        <% else %>
            <h2>
                <%= @is_you ? 'Your ' : "This person's " %>
                <%=pluralize(@display_user.info_requests.size, "Freedom of Information request") %>
                <!-- matches_estimated <%=@xapian_requests.matches_estimated%> -->
                <%= @page_desc %>
            </h2>

            <% for result in @xapian_requests.results %>
                <%= render :partial => 'request/request_listing_via_event', :locals => { :event => result[:model], :info_request => result[:model].info_request } %>
            <% end %>

            <%= will_paginate WillPaginate::Collection.new(@page, @per_page, @display_user.info_requests.size) %>
        <% end %>
    <% else %> 
        <h2>Freedom of Information requests made by <%= @is_you ? 'you' : 'this person' %> </h2>
        <p>The search index is currently offline, so we can't show the Freedom of Information requests this person has made.</p>
    <% end %> 

    <% if !@xapian_comments.nil? %>
        <% if @xapian_comments.results.empty? %>
            <% if @page == 1 %>
                <h2><%= @is_you ? 'Your' : 'This person\'s' %> annotations </h2>
                <p>None made.</p>
            <% end %>
        <% else %>
            <h2>
                <%= @is_you ? 'Your ' : "This person's " %>
                <%=pluralize(@display_user.visible_comments.size, "annotation") %>
                <!-- matches_estimated <%=@xapian_comments.matches_estimated%> -->
                <%= @page_desc %>
            </h2>

            <% for result in @xapian_comments.results %>
                <%= render :partial => 'request/request_listing_via_event', :locals => { :event => result[:model], :info_request => result[:model].info_request } %>
            <% end %>

            <%= will_paginate WillPaginate::Collection.new(@page, @per_page, @display_user.visible_comments.size) %>
        <% end %>
    <% end %>

    <% if @is_you and not @track_things.empty? %>
        <h2 id="email_subscriptions">
            Your <%=pluralize(@track_things.size, "email subscription") %>
            <% if @track_things_grouped.size == 1 %>
                <% form_tag :controller => 'track', :action => 'delete_all_type' do %>
                    <h3>
                        <%=TrackThing.track_type_description(@track_things[0].track_type)%>
                        <%= hidden_field_tag 'track_type', @track_things[0].track_type %>
                        <%= hidden_field_tag 'user', @display_user.id %>
                        <%= hidden_field_tag 'r', request.request_uri %>
                        <% if @track_things.size > 1 %>
                            <%= submit_tag "unsubscribe all" %>
                        <% end %>
                    </h3>
                <% end %>
            <% end %>
        </h2>
        <% for track_type, track_things in @track_things_grouped %>
            <% if @track_things_grouped.size > 1 %>
                <% form_tag :controller => 'track', :action => 'delete_all_type' do %>
                    <h3>
                        <%=TrackThing.track_type_description(track_type)%>
                        <%= hidden_field_tag 'track_type', track_type %>
                        <%= hidden_field_tag 'user', @display_user.id %>
                        <%= hidden_field_tag 'r', request.request_uri %>
                        <% if track_things.size > 1 %>
                            <%= submit_tag "unsubscribe all" %>
                        <% end %> 
                    </h3>
                <% end %>
            <% end %>

            <ul>
            <% for track_thing in track_things %>
                <li>
                    <% form_tag :controller => 'track', :action => 'update', :track_id => track_thing.id do %>
                        <div>
                            <%= track_thing.params[:list_description] %> 
                            <%= hidden_field_tag 'track_medium', "delete", { :id => 'track_medium_' + track_thing.id.to_s } %>
                            <%= hidden_field_tag 'r', request.request_uri, { :id => 'r_' + track_thing.id.to_s }  %>
                            <%= submit_tag "unsubscribe" %>
                        </div>
                    <% end %>
                </li>
            <% end %>
            </ul>
        <% end %>
    <% end %>

</div>