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