@@ 191-223 (lines=33) @@ | ||
188 | return DisplayActivityFollowUrl(bits[1], flag=flag) |
|
189 | ||
190 | ||
191 | def follow_all_url(parser, token): |
|
192 | """ |
|
193 | Renders the URL to follow an object as both actor and target |
|
194 | ||
195 | :: |
|
196 | ||
197 | <a href="{% follow_all_url other_user %}"> |
|
198 | {% if request.user|is_following:other_user %} |
|
199 | stop following |
|
200 | {% else %} |
|
201 | follow |
|
202 | {% endif %} |
|
203 | </a> |
|
204 | ||
205 | <a href="{% follow_all_url other_user 'watching' %}"> |
|
206 | {% is_following user group "watching" as is_watching %} |
|
207 | {% if is_watching %} |
|
208 | stop watching |
|
209 | {% else %} |
|
210 | watch |
|
211 | {% endif %} |
|
212 | </a> |
|
213 | """ |
|
214 | bits = token.split_contents() |
|
215 | if len(bits) > 3: |
|
216 | raise TemplateSyntaxError( |
|
217 | "Accepted format {% follow_all_url [instance] %} or {% follow_url [instance] [flag] %}" |
|
218 | ) |
|
219 | elif len(bits) == 2: |
|
220 | return DisplayActivityFollowUrl(bits[1], actor_only=False) |
|
221 | else: |
|
222 | flag = bits[2][1:-1] |
|
223 | return DisplayActivityFollowUrl(bits[1], actor_only=False, flag=flag) |
|
224 | ||
225 | ||
226 | def actor_url(parser, token): |
|
@@ 157-188 (lines=32) @@ | ||
154 | return IsFollowing.handle_token(parser, token) |
|
155 | ||
156 | ||
157 | def follow_url(parser, token): |
|
158 | """ |
|
159 | Renders the URL of the follow view for a particular actor instance |
|
160 | ||
161 | :: |
|
162 | ||
163 | <a href="{% follow_url other_user %}"> |
|
164 | {% if request.user|is_following:other_user %} |
|
165 | stop following |
|
166 | {% else %} |
|
167 | follow |
|
168 | {% endif %} |
|
169 | </a> |
|
170 | ||
171 | <a href="{% follow_url other_user 'watching' %}"> |
|
172 | {% is_following user group "watching" as is_watching %} |
|
173 | {% if is_watching %} |
|
174 | stop watching |
|
175 | {% else %} |
|
176 | watch |
|
177 | {% endif %} |
|
178 | </a> |
|
179 | """ |
|
180 | bits = token.split_contents() |
|
181 | ||
182 | if len(bits) > 3: |
|
183 | raise TemplateSyntaxError("Accepted format {% follow_url [instance] %} or {% follow_url [instance] [flag] %}") |
|
184 | elif len(bits) == 2: |
|
185 | return DisplayActivityFollowUrl(bits[1]) |
|
186 | else: |
|
187 | flag = bits[2][1:-1] |
|
188 | return DisplayActivityFollowUrl(bits[1], flag=flag) |
|
189 | ||
190 | ||
191 | def follow_all_url(parser, token): |