Coverage for ivatar/ivataraccount/templates/profile.html: 80%

270 statements  

« prev     ^ index     » next       coverage.py v7.8.0, created at 2025-05-12 23:12 +0000

1{% extends 'base.html' %} 

2{% load i18n %} 

3{% load static %} 

4{% load bootstrap4 %} 

5  

6{% block title %}{% trans 'Your Profile' %}{% endblock title %} 

7  

8{% block content %} 

9<script type="text/javascript"> 

10 function add_active(id){ 

11 var elems = document.querySelector(".active"); 

12 if(elems !== null){ 

13 elems.classList.remove("active"); 

14 } 

15 element = document.getElementById(id); 

16 element.classList.add("active"); 

17 } 

18</script> 

19<h1> 

20 {% trans 'Your Profile' %} - 

21 {% if user.first_name and user.last_name %} 

22 {{ user.first_name }} {{ user.last_name }} 

23 {% else %} 

24 {{ user.username }} 

25 {% endif %} 

26</h1> 

27  

28<style> 

29 .action-item:hover span { 

30 display: inline !important; 

31 } 

32 @media screen and (max-width: 320px) { 

33 .action-item, .btn { 

34 padding-left: 0.3em; 

35 padding-right: 0.3em; 

36 } 

37 } 

38 .thumbnail { 

39 max-width:80px; 

40 max-height:80px; 

41 } 

42 .nobutton { 

43 background: none; 

44 color: inherit; 

45 border: none; 

46 padding: 0; 

47 font: inherit; 

48 cursor: pointer; 

49 outline: inherit; 

50 } 

51 .button { 

52 margin-bottom: 1.5rem; 

53 margin-right: 1rem; 

54 } 

55 .container{ 

56 display: grid; 

57 } 

58 .btn-group{ 

59 display: inline-flex; 

60 } 

61 .input-group-addon{ 

62 width: auto; 

63 height: 3rem; 

64 margin-top: 0.2rem; 

65 } 

66 @media only screen and (max-width: 470px) { 

67 .button { 

68 margin-bottom: 1.5rem; 

69 margin-right: 1rem; 

70 } 

71 .unconfirmed-mail-form{ 

72 margin-bottom: 2rem; 

73 } 

74 .btn-group{ 

75 display: contents; 

76 } 

77 } 

78 @media only screen and (max-width: 470px) { 

79 p { 

80 padding-top: 2rem; 

81 } 

82 h3{ 

83 line-height: 3.4rem; 

84 } 

85 } 

86</style> 

87  

88<noscript> 

89 <style type="text/css"> 

90 .profile-container > ul{ 

91 display:block; 

92 } 

93 </style> 

94</noscript> 

95  

96{% if user.confirmedemail_set.count or user.confirmedopenid_set.count %} 

97<h3>{% trans 'You have the following confirmed identities:' %}</h3> 

98<div class="row profileid"> 

99 {% for email in user.confirmedemail_set.all %} 

100 {% if user.confirmedemail_set.all|length == 1%} 

101 <form action="{% url 'remove_confirmed_email' email.id %}" method="post"> 

102 {% csrf_token %} 

103 <div id="email-conf-{{ forloop.counter }}" class="profile-container active"> 

104 <img title="{% trans 'Access count' %}: {{ email.access_count }}" 

105 src=" 

106 {% if email.photo %} 

107 {% url 'raw_image' email.photo.id %} 

108 {% elif email.bluesky_handle %} 

109 {% url 'blueskyproxy' email.digest %} 

110 {% else %} 

111 {% static '/img/nobody/120.png' %} 

112 {% endif %}"> 

113 <h3 class="panel-title email-profile" title="{{ email.email }}"> 

114 {{ email.email }} 

115 </h3> 

116 <ul> 

117 <li> 

118 <a href="{% url 'assign_photo_email' email.id %}"> 

119 Change Profile Picture 

120 </a> 

121 </li> 

122 <li class="email-delete"> 

123 <button type="submit" class="nobutton" onclick="return confirm('{% trans 'Are you sure that you want to delete this email address?' %}')"> 

124 Delete Email Address 

125 </button> 

126 </li> 

127 </ul> 

128 </div> 

129 </form> 

130 {% else %} 

131 <form action="{% url 'remove_confirmed_email' email.id %}" method="post"> 

132 {% csrf_token %} 

133 <div id="email-conf-{{ forloop.counter }}" class="profile-container" onclick="add_active('email-conf-{{ forloop.counter }}')"> 

134 <img title="{% trans 'Access count' %}: {{ email.access_count }}" 

135 src=" 

136 {% if email.photo %} 

137 {% url 'raw_image' email.photo.id %} 

138 {% elif email.bluesky_handle %} 

139 {% url 'blueskyproxy' email.digest %} 

140 {% else %} 

141 {% static '/img/nobody/120.png' %} 

142 {% endif %}"> 

143 <h3 class="panel-title email-profile" title="{{ email.email }}"> 

144 {{ email.email }} 

145 </h3> 

146 <ul> 

147 <li> 

148 <a href="{% url 'assign_photo_email' email.id %}"> 

149 Change Profile Picture 

150 </a> 

151 </li> 

152 <li class="email-delete"> 

153 <button type="submit" class="nobutton" onclick="return confirm('{% trans 'Are you sure that you want to delete this email address?' %}')"> 

154 Delete Email Address 

155 </button> 

156 </li> 

157 </ul> 

158 </div> 

159 </form> 

160 {% endif %} 

161 {% endfor %} 

162 {% for openid in user.confirmedopenid_set.all %} 

163 {% if user.confirmedopenid_set.all|length == 1 %} 

164 <form action="{% url 'remove_confirmed_openid' openid.id %}" method="post">{% csrf_token %} 

165 <div> 

166 <div id="id-conf-{{ forloop.counter }}" class="profile-container active"> 

167 <img title="{% trans 'Access count' %}: {{ openid.access_count }}" 

168 src=" 

169 {% if openid.photo %} 

170 {% url 'raw_image' openid.photo.id %} 

171 {% elif openid.bluesky_handle %} 

172 {% url 'blueskyproxy' openid.digest %} 

173 {% else %} 

174 {% static '/img/nobody/120.png' %} 

175 {% endif %}"> 

176 <h3 class="panel-title email-profile" title="{{ openid.openid }}"> 

177 {{ openid.openid }} 

178 </h3> 

179 <ul> 

180 <li> 

181 <a href="{% url 'assign_photo_openid' openid.pk %}"> 

182 Change OpenID Picture 

183 </a> 

184 </li> 

185 <li> 

186 <button type="submit" class="nobutton" onclick="return confirm('{% trans 'Are you sure that you want to delete this OpenID?' %}')"> 

187 Delete OpenID 

188 </button> 

189 </li> 

190 </ul> 

191 </div> 

192 </div> 

193 </form> 

194 {% else %} 

195 <form action="{% url 'remove_confirmed_openid' openid.id %}" method="post">{% csrf_token %} 

196 <div> 

197 <div id="id-conf-{{ forloop.counter }}" class="profile-container" onclick="add_active('id-conf-{{ forloop.counter }}')"> 

198 <img title="{% trans 'Access count' %}: {{ openid.access_count }}" src="{% if openid.photo %}{% url 'raw_image' openid.photo.id %}{% else %}{% static '/img/nobody/120.png' %}{% endif %}"> 

199 <h3 class="panel-title email-profile" title="{{ openid.openid }}"> 

200 {{ openid.openid }} 

201 </h3> 

202 <ul> 

203 <li> 

204 <a href="{% url 'assign_photo_openid' openid.pk %}"> 

205 Change OpenID Picture 

206 </a> 

207 </li> 

208 <li> 

209 <button type="submit" class="nobutton" onclick="return confirm('{% trans 'Are you sure that you want to delete this OpenID?' %}')"> 

210 Delete OpenID 

211 </button> 

212 </li> 

213 </ul> 

214 </div> 

215 </div> 

216 </form> 

217 {% endif %} 

218 {% endfor %} 

219 </div> 

220 {% endif %} 

221  

222 {% if user.unconfirmedemail_set.count or user.unconfirmedopenid_set.count %} 

223 <h3>{% trans 'You have the following unconfirmed email addresses and OpenIDs:' %}</h3> 

224 {% for email in user.unconfirmedemail_set.all %} 

225 <form class="unconfirmed-mail-form" action="{% url 'remove_unconfirmed_email' email.id %}" method="post"> 

226 {% csrf_token %} 

227 <div class="btn-group form-group" role="group"> 

228 <button type="submit" class="button" onclick="return confirm('{% trans 'Are you sure that you want to delete this email address?' %}')"><i class="fa fa-trash"></i></button> 

229 <a href="{% url 'resend_confirmation_mail' email.pk %}" class="button"><i class="fa fa-envelope"></i></a> 

230 <span class="input-group-addon" style="width: auto;">{{ email.email }}</span> 

231 </div> 

232 </form> 

233 {# TODO: (expires in xx hours) #} 

234 {% endfor %} 

235 {% for openid in user.unconfirmedopenid_set.all %} 

236 <form action="{% url 'remove_unconfirmed_openid' openid.id %}" method="post"> 

237 {% csrf_token %} 

238 <div class="btn-group form-group" role="group"> 

239 <button type="submit" class="button" onclick="return confirm('{% trans 'Are you sure that you want to delete this OpenID?' %}')"><i class="fa fa-trash"></i></button> 

240 <span class="input-group-addon">{{ openid.openid }}</span> 

241 </div> 

242 </form> 

243 {# TODO: (expires in xx hours) #} 

244 {% endfor %} 

245 {% endif %} 

246 <p style="padding-top:5px;"> 

247 {% if not max_emails %}<a href="{% url 'add_email' %}" class="button" >{% trans 'Add a new email address' %}</a>&nbsp;{% endif %} 

248 <a href="{% url 'add_openid' %}" class="button">{% trans 'Add a new OpenID' %}</a></p> 

249 </p> 

250 {% if user.photo_set.count %} 

251 <h3>{% trans 'Here are the photos you have uploaded/imported:' %}</h3> 

252 <div class="row"> 

253 {% for photo in user.photo_set.all %} 

254 <div class="panel panel-tortin" style="width:132px;margin-left:20px;float:left"> 

255 <div class="panel-heading"> 

256 <h3 class="panel-title"><a href="{% url 'delete_photo' photo.pk %}" onclick="return confirm('{% trans 'Are you sure that you want to delete this image?' %}')"><i class="fa fa-trash"></i></a> {% trans 'Image' %} {{ forloop.counter }}</h3> 

257 </div> 

258 <div class="panel-body" style="height:130px"> 

259 <img title="{% trans 'Access count' %}: {{ photo.access_count }}" style="max-height:100px;max-width:100px" src="{% url 'raw_image' photo.id %}"> 

260 </div> 

261 </div> 

262 {% endfor %} 

263 </div> 

264 {% endif %} 

265  

266 {% if not max_photos %} 

267 <p> 

268 <a href="{% url 'upload_photo' %}" class="button">{% trans 'Upload a new photo' %}</a>&nbsp; 

269 <a href="{% url 'import_photo' %}" class="button">{% trans 'Import photo from other services' %}</a> 

270 </p> 

271 {% else %} 

272 {% trans "You've reached the maximum number of allowed images!" %}<br/> 

273 {% trans "No further images can be uploaded." %} 

274 {% endif %} 

275 <div style="height:40px"></div> 

276 {% endblock content %}