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

246 statements  

« prev     ^ index     » next       coverage.py v7.5.1, created at 2024-05-18 23:09 +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 }}" src="{% if email.photo %}{% url 'raw_image' email.photo.id %}{% else %}{% static '/img/nobody/120.png' %}{% endif %}"> 

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

106 {{ email.email }} 

107 </h3> 

108 <ul> 

109 <li> 

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

111 Change Profile Picture 

112 </a> 

113 </li> 

114 <li class="email-delete"> 

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

116 Delete Email Address 

117 </button> 

118 </li> 

119 </ul> 

120 </div> 

121 </form> 

122 {% else %} 

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

124 {% csrf_token %} 

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

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

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

128 {{ email.email }} 

129 </h3> 

130 <ul> 

131 <li> 

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

133 Change Profile Picture 

134 </a> 

135 </li> 

136 <li class="email-delete"> 

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

138 Delete Email Address 

139 </button> 

140 </li> 

141 </ul> 

142 </div> 

143 </form> 

144 {% endif %} 

145 {% endfor %} 

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

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

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

149 <div> 

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

151 <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 %}"> 

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

153 {{ openid.openid }} 

154 </h3> 

155 <ul> 

156 <li> 

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

158 Change OpenID Picture 

159 </a> 

160 </li> 

161 <li> 

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

163 Delete OpenID 

164 </button> 

165 </li> 

166 </ul> 

167 </div> 

168 </div> 

169 </form> 

170 {% else %} 

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

172 <div> 

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

174 <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 %}"> 

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

176 {{ openid.openid }} 

177 </h3> 

178 <ul> 

179 <li> 

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

181 Change OpenID Picture 

182 </a> 

183 </li> 

184 <li> 

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

186 Delete OpenID 

187 </button> 

188 </li> 

189 </ul> 

190 </div> 

191 </div> 

192 </form> 

193 {% endif %} 

194 {% endfor %} 

195 </div> 

196 {% endif %} 

197  

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

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

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

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

202 {% csrf_token %} 

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

204 <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> 

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

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

207 </div> 

208 </form> 

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

210 {% endfor %} 

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

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

213 {% csrf_token %} 

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

215 <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> 

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

217 </div> 

218 </form> 

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

220 {% endfor %} 

221 {% endif %} 

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

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

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

225 </p> 

226 {% if user.photo_set.count %} 

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

228 <div class="row"> 

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

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

231 <div class="panel-heading"> 

232 <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> 

233 </div> 

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

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

236 </div> 

237 </div> 

238 {% endfor %} 

239 </div> 

240 {% endif %} 

241  

242 {% if not max_photos %} 

243 <p> 

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

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

246 </p> 

247 {% else %} 

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

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

250 {% endif %} 

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

252 {% endblock content %}